in conclusion:
-
componentDidmount
Is only performed after assembly is fully mounted, called this methodsetState
will trigger re-rendering, most importantly, this is the official recommended! -
constructor
Calls are at the beginning, the component is not mounted, it is not used. -
componentWillMount
Callconstructor
later, here's code callssetState
will not start re-rendered, so do not. -
Another does not appear here, but most heard argument is: in
componentWillMount
a network request to render hinder the assembly's. -
Anyway, it is to be in
componentDidmount
there with!
.