Constructor action call versus lifecycle method

Where is the best place to call an action that will call the API to hydrate my state? A constructor or one of the life cycle methods, for example. ComponentWillMount?

+4
source share
1 answer

It is better to make api calls from the lifecycle method componentDidMount, it is also recommended to answer the doc.

By DOC :

componentDidMount:

componentDidMount() , . , DOM, . , . .

+3

Source: https://habr.com/ru/post/1680362/


All Articles