It might be worth revisiting react/no-did-update-set-state.
Now that componentWillReceiveProps() is being deprecated, componentDidUpdate() is the only "safe" way to detect changes in props and set state accordingly.
The React docs say calling setState() in componentDidUpdate() is permitted, albeit with caveats.
You may call setState() immediately in componentDidUpdate() but note that it must be wrapped in a condition like in the example above, or you’ll cause an infinite loop. It would also cause an extra re-rendering which, while not visible to the user, can affect the component performance.
It might be worth revisiting react/no-did-update-set-state.
Now that
componentWillReceiveProps()is being deprecated,componentDidUpdate()is the only "safe" way to detect changes in props and set state accordingly.The React docs say calling
setState()incomponentDidUpdate()is permitted, albeit with caveats.