Lifecycle method call in different states
suggest changeThis example serves as a complement to other examples which talk about how to use the lifecycle methods and when the method will be called.
This example summarizes which methods (componentWillMount, componentWillReceiveProps, and so on) are called, and how the sequence differs for a component in different states. These lists match React.createClass in React 15. Several componentWill* methods were later deprecated.
When a component is initialized:
- getDefaultProps
- getInitialState
- componentWillMount
- render
- componentDidMount
When a component has state changed:
- shouldComponentUpdate
- componentWillUpdate
- render
- componentDidUpdate
When a component has props changed:
- componentWillReceiveProps
- shouldComponentUpdate
- componentWillUpdate
- render
- componentDidUpdate
When a component is unmounting:
- componentWillUnmount
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents