I am using componentWillReceiveProps
in many places in my application. Now, I have to replace them with either getDerivedStateFromProps()
or componentDidUpdate()
. First I thought of using getDerivedStateFromProps
as it s alternative of componentWillReceiveProps
as suggested react-native
docs. But some people are highly recommending not to use this method, Instead suggesting to use componentDidUpdate
. But for my requirement all new props must be set with the state
before render. getDerivedStateFromProps
is the best place to do so.
Hence, which one to use between getDerivedStateFromProps
and componentDidUpdate
?