Migrate from react UNSAFE_componentWillReceiveProps to getDerivedStateFromProps
See original GitHub issueDescribe the issue
We current use in the Graph component the react lifecycle method componentWillReiceveProps
. This method has been deprecated in favor of getDerivedStateFromProps(props, state).
Expected
Refactor UNSAFE_componentWillReceiveProps
into getDerivedStateFromProps
.
Environment: All.
Additional context
Consider that no fundamental changes should be made in the current implementation of UNSAFE_componentWillReceiveProps
, we only want to migrate the react bits in order to keep the library compliant with the newest versions of react.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Migrating From Unsafe React Lifecycle Hooks.
The new static getDerivedStateFromProps lifecycle is invoked right before calling the render method, both on the initial mount and on subsequent ...
Read more >React17, or how to get rid of “componentWillReceiveProps”?
It should return an object to update the state, or null to update nothing. This method is useful only for state handling, and...
Read more >React.Component
constructor(); static getDerivedStateFromProps(); render(); componentDidMount() ... UNSAFE_componentWillUpdate(); UNSAFE_componentWillReceiveProps() ...
Read more >ReactJS UNSAFE_componentWillReceiveProps() Method
The componentWillReceiveProps() method has been deprecated in the latest releases of React as per this issue. It is recommended to use ...
Read more >Replacing 'componentWillReceiveProps' with ' ...
With the release of React 16.3, some new lifecycle methods have ... static getDerivedStateFromProps(nextProps, prevState){ if(nextProps.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
can I take it? it’s really simple… it already took too much time of this issue
This issue is still ongoing, it happens that the migration is not that trivial due to the flow of execution change of
getDerivedStateFromProps
which gets executed at every render…From react docs: