Component Lifecycle

React Native 6 min min read Updated: Jul 25, 2026 Intermediate
Component Lifecycle
Intermediate Topic 12 of 15

Component Lifecycle

Every React Native component goes through a lifecycle consisting of mounting, updating, and unmounting phases. Understanding this lifecycle helps developers manage side effects, data fetching, and cleanup correctly.

The Three Lifecycle Phases

  • Mounting – The component is created and inserted into the UI for the first time.
  • Updating – The component re-renders due to changes in state or props.
  • Unmounting – The component is removed from the UI.

Lifecycle in Class Components

Class components use specific lifecycle methods such as componentDidMount, componentDidUpdate, and componentWillUnmount to hook into these phases.

javascript class Example extends React.Component { componentDidMount() { console.log('Mounted'); } componentWillUnmount() { console.log('Unmounted'); } render() { return Hello; } }

Lifecycle in Functional Components

Functional components replicate lifecycle behavior using the useEffect hook, with different dependency array configurations controlling when the effect runs.

javascript useEffect(() => { console.log('Mounted'); return () => { console.log('Unmounted'); }; }, []);

Handling Updates

To respond to updates in specific values, include those values in the dependency array of useEffect, causing the effect to re-run whenever they change.

javascript useEffect(() => { console.log('Count updated:', count); }, [count]);

Why Lifecycle Understanding Matters

Knowing when a component mounts, updates, or unmounts is crucial for correctly managing subscriptions, timers, API calls, and cleanup logic to avoid memory leaks and unexpected behavior.

Conclusion

While class-based lifecycle methods are still found in legacy codebases, modern React Native development relies on the useEffect hook to manage the same mounting, updating, and unmounting behavior in functional components.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators