Redux in React Native: Learn with Code Examples | Updated 2025

Redux in React Native: Step-by-Step Guide with Code Samples

Functional Programming vs OOP Article

About author

Deepan (Mobile App Developer )

Deepan is a mobile app architect who simplifies state management in React Native using Redux and middleware tools. He explains how to structure actions, reducers, and stores for scalable, maintainable applications. His content empowers developers to build predictable data flows with clean code and real-world examples.

Last updated on 31st Oct 2025| 11456

(5.0) | 32961 Ratings

Redux in React Native

In modern mobile app development, managing the flow of data and application state can be challenging especially as apps grow in complexity. Redux is a powerful state management library that helps developers maintain predictable, centralized, and easily testable application states. In React Native, where user interfaces are dynamic and involve frequent data updates, Redux plays a crucial role in ensuring that components remain in sync with the app’s overall data flow. Redux acts as a single source of truth for all shared states in your application, allowing for more consistent and maintainable code. By integrating Redux with React Native, developers can separate business logic from UI components, improve scalability, and enhance debugging capabilities all while ensuring the app behaves predictably across different devices and user actions.

    Subscribe To Contact Course Advisor

    Why Use Redux for State Management?

    React Native has state management tools like React’s Context API and the useState and useReducer hooks. However, large apps can make managing state tricky. That’s where Redux is useful. A key benefit of Redux in React Native is central management of state. It puts all states into one global object, the store. This cuts down on confusion from different component states and makes data access easier across screens. Redux also makes sure state changes happen in a clear way. Actions say what happened, and reducers say how the state changes. This consistency makes the app easier to understand and debug. Redux uses pure functions for reducers, so testing state changes is easy. Tools like Redux DevTools can also help track changes. Redux helps keep things consistent because everything uses the same store.


    Are You Interested in Learning More About Full Stack Developer? Sign Up For Our Full Stack Developer Training Today!


    Setting Up Redux in a React Native App

    Setting up Redux in a React Native project is straightforward. Below is the general setup process:

    Setting Up Redux in a React Native App Article
    • npm install redux react-redux

    Create a Simple Store:

    • import { createStore } from ‘redux’;
    • import rootReducer from ‘./reducers’;
    • const store = createStore(rootReducer);
    • export default store;

    Provide the Store to the App:

    • import React from ‘react’;
    • import { Provider } from ‘react-redux’;
    • import store from ‘./src/redux/store’;
    • import MainApp from ‘./src/components/MainApp’;
    • export default function App() {
    • return (
    • <Provider store={store}>
    • <MainApp />
    • </Provider>
    • );
    • }

    This ensures every component within the app can access Redux state and dispatch actions.


    Would You Like to Know More About Full Stack Developer? Sign Up For Our Full Stack Developer Training Now!


    Understanding Redux Actions and Reducers

    In Redux, actions and reducers are the core mechanisms that define how state changes occur.

    Actions:

    Actions are plain JavaScript objects that describe what happened in the app. Each action has a type and an optional payload.

    • export const increment = () => ({
    • type: ‘INCREMENT’,
    • });

    Reducers:

    Reducers are pure functions that determine how the state changes in response to actions. They take the current state and an action as input and return a new state.

    • const initialState = { count: 0 };
    • const counterReducer = (state = initialState, action) => {
    • switch (action.type) {
    • case ‘INCREMENT’:
    • return { …state, count: state.count + 1 };
    • case ‘DECREMENT’:
    • return { …state, count: state.count – 1 };
    • default:
    • return state;
    • }
    • };

    Reducers never mutate the state directly; instead, they return a new copy, ensuring immutability and predictability.

    Course Curriculum

    Develop Your Skills with Full Stack Developer Certification Training

    Weekday / Weekend BatchesSee Batch Details

    Creating a Redux Store in React Native

    The store is the heart of Redux, it holds the entire state tree of your application.

    • import { combineReducers } from ‘redux’;
    • import counterReducer from ‘./counterReducer’;
    • import userReducer from ‘./userReducer’;
    • const rootReducer = combineReducers({
    • counter: counterReducer,
    • user: userReducer,
    • });
    • export default rootReducer;
    • import { createStore, applyMiddleware } from ‘redux’;
    • import thunk from ‘redux-thunk’;
    • import rootReducer from ‘./reducers’;
    • const store = createStore(rootReducer, applyMiddleware(thunk));
    • export default store;

    This store acts as the central hub for data management, enabling any connected component to access and modify the global state.


    Connecting Components to Redux Store

    Once the store is set up, React Native components can access the Redux state using hooks or higher-order components.

    • import React from ‘react’;
    • import { useSelector, useDispatch } from ‘react-redux’;
    • import { increment } from ‘../redux/actions/counterActions’;
    • const Counter = () => {
    • const count = useSelector(state => state.counter.count);
    • const dispatch = useDispatch();
    • return (
    • <>
    • <Text>Count: {count}</Text>
    • <Button title=”Increment” onPress={() => dispatch(increment())} />
    • </>
    • );
    • };
    • export default Counter;
    • // Using connect() function
    • import { connect } from ‘react-redux’;
    • import { increment } from ‘../redux/actions’;
    • const Counter = ({ count, increment }) => (
    • <>
    • <Text>Count: {count}</Text>
    • <Button title=”+” onPress={increment} />
    • </>
    • );
    • const mapStateToProps = state => ({
    • count: state.counter.count,
    • });

    These methods ensure that the component automatically re-renders when the Redux state changes.

    Preparing for Full Stack Development Job? Have a Look at Our Blog on Full Stack Development Interview Questions and Answers To Ace Your Interview!


    Using Redux Middleware (Thunk/Saga)

    Middleware extends Redux’s capabilities by handling asynchronous logic and side effects like API calls.

    • export const fetchUser = () => async (dispatch) => {
    • dispatch({ type: ‘FETCH_USER_REQUEST’ });
    • try {
    • const response = await fetch(‘https://api.example.com/user’);
    • const data = await response.json();
    • dispatch({ type: ‘FETCH_USER_SUCCESS’, payload: data });
    • } catch (error) {
    • dispatch({ type: ‘FETCH_USER_FAILURE’, error });
    • }
    • };

    Handling API Calls with Redux

    API calls are a common use case for Redux. With Thunk or Saga, you can easily handle network requests while maintaining predictable state transitions.

    Handling API Calls with Redux Article

    Typical flow:

    • Dispatch a request action before the API call.
    • Dispatch a success or failure action based on the response.
    • Update UI accordingly using Redux state.

    This approach standardizes data fetching across your app and avoids cluttering UI components with async logic.


    Full Stack Development Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

    Managing Async State in Redux

    Async state involves data that changes over time, such as network requests or real-time updates. Redux manages async state by maintaining different loading phases:

    • const initialState = {
    • loading: false,
    • data: [],
    • error: null,
    • };
    • function dataReducer(state = initialState, action) {
    • switch (action.type) {
    • case ‘FETCH_START’:
    • return { …state, loading: true };
    • case ‘FETCH_SUCCESS’:
    • return { …state, loading: false, data: action.payload };
    • case ‘FETCH_FAILURE’:
    • return { …state, loading: false, error: action.error };
    • default:
    • return state;
    • }
    • }

    By explicitly managing loading, success, and error states, you can provide better user feedback and prevent inconsistent UI behavior during asynchronous operations.

    Optimizing Redux Performance in React Native

    While Redux provides structure, it can introduce performance issues if not optimized properly. Some optimization techniques include:

    • Use React.memo or useMemo: Prevent unnecessary re-renders of components.
    • Split Reducers Logically: Avoid one massive reducer; use multiple reducers for modularity.
    • Normalize Data: Store data in a normalized form to reduce duplication.
    • Selective Component Subscription: Use useSelector carefully subscribe only to required state slices.
    • Avoid Inline Functions in Components: Inline functions trigger re-renders; move them outside or use useCallback.
    • Leverage Reselect Library: Create memoized selectors to compute derived data efficiently.

    By applying these techniques, you ensure that Redux-powered React Native apps remain fast, efficient, and scalable.


    Conclusion

    In conclusion, Redux is an indispensable tool for managing complex state in React Native applications. It brings structure, predictability, and consistency to app development by centralizing state management and enforcing a unidirectional data flow. From handling asynchronous API calls to optimizing performance, Redux enables developers to build scalable and maintainable mobile applications. While it may add some setup overhead, the long-term benefits in debugging, performance, and collaboration are substantial. By following best practices and leveraging middleware like Redux Thunk or Redux Saga, developers can create robust React Native apps that are easy to maintain, test, and expand as business requirements evolve.

    Upcoming Batches

    Name Date Details
    Full Stack Developer Training

    27 - Oct - 2025

    (Weekdays) Weekdays Regular

    View Details
    Full Stack Developer Training

    29 - Oct - 2025

    (Weekdays) Weekdays Regular

    View Details
    Full Stack Developer Training

    01 - Nov - 2025

    (Weekends) Weekend Regular

    View Details
    Full Stack Developer Training

    02 - Nov - 2025

    (Weekends) Weekend Fasttrack

    View Details