React Redux Bindings

9.2.0 · active · verified Sun Apr 19

React Redux is the official set of React bindings for the Redux state management library. It provides utilities and hooks like `Provider`, `useSelector`, `useDispatch`, and `connect` to integrate Redux stores with React components efficiently. The current stable version is 9.2.0, which includes compatibility for React 19. The package typically follows a release cadence that aligns with major React and Redux core updates, with bugfix and minor feature releases occurring regularly. Key differentiators include its official status, deep integration with the Redux ecosystem, and optimizations for performance in large-scale React applications, such as automatic batching of updates with React 18+.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates setting up a basic Redux store with `createStore`, providing it to a React application via `Provider`, and consuming the state and dispatching actions in a functional component using the `useSelector` and `useDispatch` hooks. It includes basic TypeScript types for the state.

import React from 'react';
import { createStore } from 'redux';
import { Provider, useSelector, useDispatch } from 'react-redux';

// Redux Store Setup
interface RootState { count: number; }
const initialState: RootState = { count: 0 };

function counterReducer(state = initialState, action: { type: string }) {
  switch (action.type) {
    case 'increment': return { count: state.count + 1 };
    case 'decrement': return { count: state.count - 1 };
    default: return state;
  }
}

const store = createStore(counterReducer);

// React Component
function Counter() {
  const count = useSelector((state: RootState) => state.count);
  const dispatch = useDispatch();

  return (
    <div>
      <h1>Count: {count}</h1>
      <button onClick={() => dispatch({ type: 'increment' })}>+</button>
      <button onClick={() => dispatch({ type: 'decrement' })}>-</button>
    </div>
  );
}

// App Root
function App() {
  return (
    <Provider store={store}>
      <Counter />
    </Provider>
  );
}

export default App;

view raw JSON →