Forget this ridiculous separation of duties. сomponentDidMount and componentDidUpdate only hooks lifecycle to be applied where there is a need to use them.
Vernie.Johnson91 answered on March 19th 20 at 08:53
Since React v16.8 recommended React Hooks to create new components.
In your case you should use useEffect Hook.
More about this you can read on the official website of React: https://reactjs.org/docs/hooks-effect.html