AskHandle

AskHandle Blog

How to Handle State Management in React Native

September 4, 2025Elise Taylor3 min read

How to Handle State Management in React Native

Are you struggling with state management in your React Native application? Managing state is key to building effective mobile apps with React Native. It helps track data changes and ensures a smooth user experience. This article presents various methods and best practices for state management in React Native.

Local Component State

One of the easiest ways to manage state in React Native is using local component state. You can define a state variable with the useState hook from React and update it as needed.

jsx
1import React, { useState } from 'react';
2import { Text, Button, View } from 'react-native';
3
4const Counter = () => {
5  const [count, setCount] = useState(0);
6
7  const increment = () => {
8    setCount(count + 1);
9  };
10
11  return (
12    <View>
13      <Text>Count: {count}</Text>
14      <Button title="Increment" onPress={increment} />
15    </View>
16  );
17};
18
19export default Counter;

Local component state works well for individual components. For sharing state across multiple components or handling complex state logic, consider other options.

Context API

The Context API allows you to share state across multiple components without passing props manually down the tree. This is particularly useful for global state management in React Native applications.

You can create a context and a provider to make the state accessible to all descendant components.

jsx
1import React, { createContext, useContext, useState } from 'react';
2import { Text, Button, View } from 'react-native';
3
4const CountContext = createContext();
5
6const Counter = () => {
7  const [count, setCount] = useState(0);
8
9  const increment = () => {
10    setCount(count + 1);
11  };
12
13  return (
14    <CountContext.Provider value={{ count, increment }}>
15      <CounterDisplay />
16    </CountContext.Provider>
17  );
18};
19
20const CounterDisplay = () => {
21  const { count, increment } = useContext(CountContext);
22
23  return (
24    <View>
25      <Text>Count: {count}</Text>
26      <Button title="Increment" onPress={increment} />
27    </View>
28  );
29};
30
31export default Counter;

Using the Context API allows efficient global state management in your React Native app without prop drilling.

Redux

Redux is a widely-used state management library for React and React Native applications. It provides a predictable state container accessible from any component. Redux is great for managing complex state and data flow in large applications.

To integrate Redux into your app, define actions, reducers, and a store. Actions send data to the Redux store, while reducers specify how the state changes in response to those actions.

jsx
1// actions.js
2export const increment = () => ({
3  type: 'INCREMENT',
4});
5
6// reducers.js
7const initialState = { count: 0 };
8
9const counterReducer = (state = initialState, action) => {
10  switch (action.type) {
11    case 'INCREMENT':
12      return { ...state, count: state.count + 1 };
13    default:
14      return state;
15  }
16};
17
18export default counterReducer;
jsx
1// store.js
2import { createStore } from 'redux';
3import counterReducer from './reducers';
4
5const store = createStore(counterReducer);
6
7export default store;

With Redux, access the global state using the connect higher-order component from React-Redux.

jsx
1import React from 'react';
2import { Text, Button, View } from 'react-native';
3import { connect } from 'react-redux';
4import { increment } from './actions';
5
6const Counter = ({ count, increment }) => {
7  return (
8    <View>
9      <Text>Count: {count}</Text>
10      <Button title="Increment" onPress={increment} />
11    </View>
12  );
13};
14
15const mapStateToProps = state => ({
16  count: state.count,
17});
18
19export default connect(mapStateToProps, { increment })(Counter);

MobX

MobX offers a simpler alternative to Redux for state management. It allows you to define observables, actions, and reactions for managing state in your React Native application.

With MobX, create observable stores that maintain the state of your app and modify them using actions.

jsx
1import { makeObservable, observable, action } from 'mobx';
2
3class CounterStore {
4  count = 0;
5
6  constructor() {
7    makeObservable(this, {
8      count: observable,
9      increment: action,
10    });
11  }
12
13  increment() {
14    this.count++;
15  }
16}
17
18export default new CounterStore();
jsx
1import React from 'react';
2import { Text, Button, View } from 'react-native';
3import { observer } from 'mobx-react';
4import counterStore from './CounterStore';
5
6const Counter = observer(() => {
7  const increment = () => {
8    counterStore.increment();
9  };
10
11  return (
12    <View>
13      <Text>Count: {counterStore.count}</Text>
14      <Button title="Increment" onPress={increment} />
15    </View>
16  );
17});
18
19export default Counter;

Effective state management is crucial for building scalable React Native applications. Choose the right state management solution, whether it's local component state, Context API, Redux, or MobX, to structure your app properly and ensure optimal performance.