React lifecycle Flashcards
What is the “mount” phase of the component lifecycle?
When a React component renders to the DOM for the first time.
When does a components unmounting period occur?
A component’s unmounting period occurs when the component is removed from the DOM.
What is a common reason for a component to be removed from the DOM?
When the DOM re-renders without the component.
For example when you change page in a React app lots of components will not be displayed, they will be unmounted.
What are the three stages of the React lifecycle?
mounting, updating, and unmounting.
Does a component always go through every stage of the React lifecycle?
No, a React component may not go through every phase. For example, a component could be mounted one minute and then unmounted the next without any updates or error handling.