-
Notifications
You must be signed in to change notification settings - Fork 408
fix warning at #2680 #2681
fix warning at #2680 #2681
Conversation
https://reactjs.org/docs/react-component.html#shouldcomponentupdate `UNSAFE_componentWillReceiveProps`: https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops
icecream17
commented
May 14, 2021
@smashwilson
smashwilson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should work 👍🏻
It looks like we have another use of componentWillReceiveProps in the codebase, though. Can we leave the linked issue open until that's converted, as well?
smashwilson
commented
May 14, 2021
The tests failed, but for external reasons
Yeah, our CI seems really unhealthy 😒 . It was always a bit rickety even when this was my major focus, but it looks like entropy has made it even worse since the last time I've done work here.
`_prevProps` is unused, that's why it has an underscore. Maybe atom does something differently?
Codecov Report
@@ Coverage Diff @@ ## master #2681 +/- ## ======================================= Coverage 93.46% 93.46% ======================================= Files 237 237 Lines 13213 13213 Branches 1900 1900 ======================================= Hits 12349 12349 Misses 864 864
Continue to review full report at Codecov.
|
icecream17
commented
Sep 2, 2021
That last commit was for the tests to run
Uh oh!
There was an error while loading. Please reload this page.
Please be sure to read the contributor's guide to the GitHub package before submitting any pull requests.
Description of the Change
componentWillRecievePropsis now deprecated, so this pr replaces it.https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops says:
"If you need to perform a side effect (for example, data fetching or an animation) in response to a change in props, use
componentDidUpdatelifecycle instead."componentDidUpdateis called after updating, rather thancomponentWillRecieveProps.If this (or some other subtle change) happens to break atom, then I'll just use
UNSAFE_componentWillReceivePropsinstead.Warning text:
Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.
npx react-codemod rename-unsafe-lifecyclesin your project source folder.In this case, it's used for side effects (1st bullet point)
And this implies there will still be a warning when using
UNSAFE_componentWillReceivePropsin strict-mode, so tryingcomponentDidUpdatefirst.Screenshot or Gif
N/A
Applicable Issues
(削除) Fixes (削除ここまで)(削除) Part of (削除ここまで)Fixes #2680