What are the phases of a React class component lifecycle?
Three phases: mounting when the component is added to the DOM, updating when it re-renders due to state or props changes, and unmounting when it is removed. Each phase has lifecycle methods that run at specific points.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in React Class Component Lifecycle Methods Explained With Examples
It runs after the component is added to the DOM. You use it to fetch data, set up subscriptions, and start timers, similar to useEffect with an empty dependency array in functional components.
It runs right before the component is removed from the DOM. You use it to clean up subscriptions, timers, and listeners to prevent memory leaks, similar to the cleanup function returned from useEffect.
It runs after an update is committed to the DOM, when state or props change. You use it to respond to changes, like fetching new data when a prop changes, similar to useEffect with dependencies.
Still have questions?
Browse all our FAQs or reach out to our support team
