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 aclasscomponent.render()method should be pure, meaning that it does not modify component'sstate(don't use thesetStateinside).- This method structures and prepares the JSX, and returns React elements.
- After the
renderis done the React component “mounts” onto the DOM.