moroshko / react-autosuggest

WAI-ARIA compliant React autosuggest component
http://react-autosuggest.js.org
MIT License
5.97k stars 586 forks source link

Warning about `componentWillReceiveProps` in React's Strict Mode #624

Open ulrichb opened 5 years ago

ulrichb commented 5 years ago

React's Strict Mode warns about "Unsafe lifecycle methods were found within a strict-mode tree".

componentWillReceiveProps: Please update the following components to use static getDerivedStateFromProps instead.

https://github.com/moroshko/react-autosuggest/blob/d626cef720df0ed5a4c7df4d539836b86bda6afa/src/Autosuggest.js#L124-L143

ulrichb commented 5 years ago

Now with React 16.9 it's even a non-strict mode warning ...

Kove11 commented 5 years ago

Any update on this @moroshko ?

ghost commented 4 years ago

Still very relevant, looking forward to updates

rlueder commented 4 years ago

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

aberezkin commented 4 years ago

Fixed in #681

wzijden commented 4 years ago

@aberezkin this should not have been closed. It resolves https://github.com/moroshko/react-autosuggest/issues/670, but not this one. A warning is still shown in React's strictmode:

Warning: Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code.
aberezkin commented 4 years ago

Can someone work on this?

adi518 commented 3 years ago

Fixed in #681

It doesn't fix this warning for strict mode. To fix this issue the implementation has to change to this lifecycle: https://reactjs.org/docs/react-component.html#static-getderivedstatefromprops.

Links from the snippet below:

index.js:1 Warning: Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code. See https://reactjs.org/link/unsafe-component-lifecycles 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://reactjs.org/link/derived-state

Please update the following components: Autosuggest, Autowhatever
reft commented 2 years ago

still not fixed¿¿

image

QQ

"react": "^17.0.2",