component lifecycle events:
- React lets you define components as classes or functions.
- The methods that you are able to use classes or functions(components) these are called lifecycle events.
- Allow you to update the UI and application states.
Based off the diagram, what happens first, the ‘render’ or the ‘componentDidMount’?
- render
What is the very first thing to happen in the lifecycle of React?
- Mounting phase.
Put the following things in the order that they happen: componentDidMount, render, constructor, componentWillUnmount, React Updates
- constructor , render , componentDidMount ,React update , componentWillUnmount.
What does componentDidMount do?
- If you need to load anything using a network request or initialize the DOM, it should go here. This method is a good place to set up any subscriptions. If you do that, don’t forget to unsubscribe in componentWillUnmount().