Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated lifecycle method warnings with React 16.9 #844

Closed
taylon opened this issue Aug 20, 2019 · 3 comments · Fixed by #847
Closed

Deprecated lifecycle method warnings with React 16.9 #844

taylon opened this issue Aug 20, 2019 · 3 comments · Fixed by #847

Comments

@taylon
Copy link

taylon commented Aug 20, 2019

Hi,

The following warning is shown upon upgrading to React 16.9:

Warning: componentWillMount has been renamed, and is not recommended for use. See https://fb.me/react-async-component-lifecycle-hooks for details.
      
      * Move code with side effects to componentDidMount, and set initial state in the constructor.
      * Rename componentWillMount to UNSAFE_componentWillMount to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.

I guess a quick temporary fix would be to use the codemod to rename everything but I'm not sure if that has any other impact.

@gabrielliwerant
Copy link
Collaborator

gabrielliwerant commented Aug 20, 2019

Yes, I've been aware of this issue for a while, but might as well switch to the unsafe API now. I'd like to handle the actual removal in a different release to help isolate any breakage, but this will get us started: #847.

@codealchemy
Copy link

I noticed these warnings when using this library as well and am looking forward to the patch - might the version of React need to be bumped as a part of this (ie. in peerDependencies)? It seems that these aliases were introduced in React 16.3.

@gabrielliwerant
Copy link
Collaborator

peerDependencies could probably use a bump at some point, but the version in the lockfile is high enough, and new installations of the library will install what's specified in the lockfile, so we're good there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants