4 ms·
If you are doing asynchronous data fetching in your components, only using those three lifecycle methods will inevitably lead to bugs when your props or state u
by richeyryan 6y ago
If you are doing asynchronous data fetching in your components, only using those three lifecycle methods will inevitably lead to bugs when your props or state update but your asynchronous call doesn't fire again because it was in componentDidMount. You need to use componentDidUpdate to trigger the call again when props or state update. Alternatively useEffect with the dependency array properly filled won't allow a stale state like that to occur.