React-autosuggest: Warning about `componentWillReceiveProps` in React 16.9.0

Created on 14 Aug 2019  路  13Comments  路  Source: moroshko/react-autosuggest

react-dom.development.js:11494 Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-async-component-lifecycle-hooks for details.

* Move data fetching code or side effects to componentDidUpdate.
* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state
* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps 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.

Please update the following components: Autosuggest, Autowhatever

Can be auto fixed with

npx react-codemod rename-unsafe-lifecycles <path>

Most helpful comment

@fatso83 yea that's fine temporarily but if the repo will never be updated i'll probably just look for alternatives

All 13 comments

Duplicate of #624.

@ChrisWiles Renaming is not a fix. That's a temporary band-aid to suppress the warning. The warning has a _meaning_; the method is being removed in the next major version, so you need to refactor the internals, for instance using the static getDerivedStateFromProps method to toggle flags.

You still have a while before react 17, so while you refactor your library you could at least add unsafe in the meantime which takes no time and little effort

Actually, the UNSAFE_ lifecycle methods will still exist in React 17. So switching everything to use the UNSAFE prefix will make it work in React 17 as well!

Yes please add UNSAFE_ prefix while the code is being refactored. Otherwise it will break in React 17

bump. @moroshko if someone made a PR to address this would you merge it? It would be great to have this fixed before react 17 comes out. otherwise this library will no longer work.

Just fork it, publish a namescoped version to the NPM registry and change your dependencies to use that. Done.

@fatso83 yea that's fine temporarily but if the repo will never be updated i'll probably just look for alternatives

react-dom.development.js:11494 Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-async-component-lifecycle-hooks for details.

* Move data fetching code or side effects to componentDidUpdate.
* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state
* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps 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.

Please update the following components: Autosuggest, Autowhatever

Can be auto fixed with

npx react-codemod rename-unsafe-lifecycles <path>

hello , any help regarding path , iused following path but it didn't do anything

npx react-codemod rename-unsafe-lifecycles /Users/username/Documents/react/projectname/node_modules/react-autosuggest/dist/Autosuggest.js

Here's a PR that should take care of it: https://github.com/moroshko/react-autosuggest/pull/681

Fixed in #681

@aberezkin Thanks! been waiting on this for a while now.

@aberezkin Also thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Razinsky picture Razinsky  路  3Comments

cristian-sima picture cristian-sima  路  3Comments

jerrylow picture jerrylow  路  3Comments

marclemagne picture marclemagne  路  4Comments

AlgoTrader picture AlgoTrader  路  3Comments