These methods are called in the following order when an instance of a component is created and inserted into the DOM:
- constructor()
- render() ⬅
- componentDidMount()
- The
render()
lifecycle method is the next in line lifecycle method called right after theconstructor
. render()
is the only required method in aclass
component.render()
method should be pure, meaning that it does not modify component'sstate
(don't use thesetState
inside).- This method structures and prepares the JSX, and returns React elements.
- After the
render
is done the React component “mounts” onto the DOM.