N
N
Newbie Ivanovich2019-03-27 10:44:30
React
Newbie Ivanovich, 2019-03-27 10:44:30

Where should componentDidMount and componentDidUpdate be placed?

where should the specified components be placed in the container or directly in the component that does the rendering?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
drboboev, 2019-03-27
@NovichokIvanovich

In the component you are rendering.

A
Anton Spirin, 2019-03-27
@rockon404

Forget this ridiculous division of duties. componentDidMount and componentDidUpdate are just lifecycle hooks that need to be applied where there is a need to use them.

I
iDzyubin, 2019-03-29
@iDzyubin

As of React v16.8, it is recommended to use React Hooks to create new components.
In your case, you should use useEffect Hook.
You can read more about this on the official React website:
https://reactjs.org/docs/hooks-effect.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question