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

componentWillReceiveProps has been renamed #140

Closed
jaexplorer opened this issue Oct 4, 2019 · 11 comments
Closed

componentWillReceiveProps has been renamed #140

jaexplorer opened this issue Oct 4, 2019 · 11 comments

Comments

@jaexplorer
Copy link

  • 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: InfiniteScroll

I get this warning in my console constantly. Am I using InfiniteScroll incorrectly or this legit something that needs to be addressed?

@edekk
Copy link

edekk commented Oct 11, 2019

To overcome this issue browse
{your_project}\node_modules\react-infinite-scroll-component\lib\index.js
and change:
key: "componentWillReceiveProps", value: function componentWillReceiveProps(props) { ...
into:
key: "componentDidUpdate", value: function componentDidUpdate(props) {...

Keep in mind you edit the build version, so for good measure you could also edit pre-build file
({your_project}\node_modules\react-infinite-scroll-component\app\index.js) and change function names there as well.

@Falkyouall
Copy link

this should be patched by the authors asap. the only other way i see here is to apply npm patch-package. this will edit the wrong-ish npm module every time you type npm install, and therefore the only sustainable way to accomplish this besides waiting for a new release.

@ankeetmaini
Copy link
Owner

ankeetmaini commented Jan 15, 2020 via email

@Falkyouall
Copy link

@ankeetmaini thank you.

@ankeetmaini
Copy link
Owner

@Falkyouall latest release has this change? I see in master the method was renamed to "UNSAFE_ComponentWillReceiveProps". You shouldn't be getting any warnings.

@AmitNeuhaus
Copy link

Im still seeing this warning when using the official npm install package.
am i doing something wrong?

@NithinRauj
Copy link

To overcome this issue browse
{your_project}\node_modules\react-infinite-scroll-component\lib\index.js
and change:
key: "componentWillReceiveProps", value: function componentWillReceiveProps(props) { ...
into:
key: "componentDidUpdate", value: function componentDidUpdate(props) {...

Keep in mind you edit the build version, so for good measure you could also edit pre-build file
({your_project}\node_modules\react-infinite-scroll-component\app\index.js) and change function names there as well.

Hey @ankeetmaini I am also getting the same warning message.So I tried doing this fix but I couldn't find a lib folder in my node_modules.So how to fix this error ? By the way I also used the official npm package.

@akkisagiraju
Copy link

Using this in strict mode is resulting in a warning message.

Warning: Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code.

@tigerblue77
Copy link

Why close ? This issue is still present in strict mode... How to fix it ?

@ali-taghipour
Copy link

It has trouble. It didn't fix. What should I do?

@Comediant24
Copy link

I agree! The problem is not solved!

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

No branches or pull requests

10 participants