What are the lifecycle phases of a React component?
Mounting, updating, and unmounting. Mounting is when the component is added to the DOM, updating is when it re-renders due to state or props changes, and unmounting is when it is removed.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in React Lifecycle and Class Component Interview Questions
It runs after the component is added to the DOM. You fetch data, set up subscriptions, and start timers here. It maps to useEffect with an empty dependency array in functional components.
It runs right before the component is removed from the DOM. You clean up subscriptions, timers, and listeners here to prevent leaks. It maps to the cleanup function returned from useEffect.
componentDidMount runs once, after mount. componentDidUpdate runs after every update caused by state or props changes. They handle different moments in the component lifecycle.
Still have questions?
Browse all our FAQs or reach out to our support team
