react-helmet-async icon indicating copy to clipboard operation
react-helmet-async copied to clipboard

using UNSAFE_componentWillMount in strict mode

Open ali-eljerrari opened this issue 2 years ago • 1 comments

Warning: Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. See https://reactjs.org/link/unsafe-component-lifecycles for details.

  • Move code with side effects to componentDidMount, and set initial state in the constructor.

Please update the following components: SideEffect(NullComponent2)

any fix for this warning???

ali-eljerrari avatar Jan 04 '24 16:01 ali-eljerrari

After some extensive debugging of the code, I've determined that componentWillMount in the Dispatcher.tsx file is firing after the init when using this package in a NextJS project. This causes the helmetInstances object to be removed and never gets applied. This is the only reason no one is able to use this package for client side <head> updates in NextJS's new App routing! I'm guessing this affects other similar frameworks as well.

As per the 6 year old note in the code

  // componentWillMount will be deprecated
  // for SSR, initialize on first render
  // constructor is also unsafe in StrictMode

Can that simply be removed entirely?

(side note: componentDidUpdate never even fires)

gilluminate avatar Jan 08 '24 20:01 gilluminate