Where to place the logic for loading the source server data in a React application?

I am using React-Redux to build an application.

To load the source data for the React smart component, I need to send a Redux action where data requests from the server will be executed.

I tried to submit the action in the constructor (ES6 implementation), componentWillMountand componenetDidMount. They all worked.


My question is:

Does the React Intelligent component have a recommended location for submitting the action?

+6
source share
2 answers

Edit : Dan Abramov recently announced

React , componentWillMount , componentDidMount .


componentDidMount

.

DidMount. , , .

componentWillUnmount , .

" componentDidMount". , componentWillMount , , , componentDidMount .

+7

, , DidMount. . this.

+1

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


All Articles