useState Hook
The useState hook is one of the most frequently used hooks in React Native, allowing functional components to hold and update local state. This tutorial covers useState in depth with practical examples.
Basic Syntax
The useState hook returns an array containing the current state value and a function used to update it.
Updating State
To update state, call the setter function returned by useState. This automatically triggers a re-render of the component with the updated value.
Using Functional Updates
When the new state depends on the previous state, especially in rapid updates, always use the functional form to avoid stale closures.
Managing Multiple State Variables
A component can use multiple useState calls to manage several independent pieces of state, keeping each piece of data separate and easier to reason about.
Managing Object State
When state holds an object, always spread the previous state before updating specific fields to avoid accidentally overwriting other properties.
Lazy Initial State
For expensive computations, useState accepts a function that only runs once during the initial render, improving performance.
Common Mistakes with useState
- Mutating state directly instead of using the setter function
- Relying on stale state values inside asynchronous callbacks
- Overusing multiple useState calls when a single object might be cleaner
Conclusion
The useState hook is fundamental to building interactive React Native components. Understanding functional updates, object state handling, and lazy initialization ensures your components behave predictably and efficiently.

