React-Redux is the official package that helps React applications connect with Redux state management. Redux Toolkit is a newer, more user-friendly package that simplifies Redux development by including useful tools and reducing boilerplate code. While React-Redux focuses on connecting React and Redux, Redux Toolkit provides a complete solution with built-in best practices and helper functions.
React-Redux is a state management library that connects React components to a Redux store. Redux Toolkit is a set of tools for building Redux applications, including a simplified store setup, action creators, and reducers. Redux Toolkit is built on top of React-Redux.
Both packages have excellent TypeScript support, with React-Redux having a dedicated @types/react-redux package and Redux Toolkit having built-in TypeScript definitions.
Both packages are compatible with modern browsers, including Chrome, Firefox, Safari, and Edge.
React-Redux has no dependencies, while Redux Toolkit depends on Redux and react-redux.
Both packages have excellent performance characteristics, with React-Redux being more lightweight and Redux Toolkit providing more features out of the box.
Both packages are compatible with React, but Redux Toolkit is more flexible and can be used with other frameworks.
React-Redux has a larger and more active community, with more contributors and issues closed.
Both packages have excellent documentation, with React-Redux having more extensive guides and Redux Toolkit having more concise API references.
Both packages are actively maintained, with React-Redux having a more frequent release cycle.
1import React from 'react';
2import { createStore } from 'redux';
3import { Provider, connect } from 'react-redux';
4
5const store = createStore(() => {});
6
7const App = () => {
8 return <Provider store={store}><div>Hello World!</div></Provider>;
9};
This example shows how to set up a basic React-Redux application with a store and a connected component.
1import { configureStore } from '@reduxjs/toolkit';
2import { createSlice } from '@reduxjs/toolkit';
3
4const counterSlice = createSlice({
5 name: 'counter',
6 initialState: 0,
7 reducers: {
8 increment: (state) => state + 1,
9 },
10});
11
12const store = configureStore({
13 reducer: counterSlice.reducer,
14});
This example shows how to set up a basic Redux Toolkit application with a slice and a configured store.
Both packages are excellent choices for state management in React applications, but Redux Toolkit provides more features out of the box and is more flexible.
A tiny state management solution that uses hooks. It's much simpler than Redux and requires way less code to get started. Perfect for small to medium React applications.
It's a great alternative because it's easier to learn than Redux, has zero dependencies, and doesn't need any wrapping Provider components. You can start using it in minutes without complex setup.
State ManagementFacebook's own state management library that works with atoms (small pieces of state) and selectors. It's built specifically for React and handles complex state requirements really well.
Created by Facebook (like React), it's great for large applications that need to manage lots of data. It's especially good at handling derived state and async data.
State ManagementA state management tool that breaks down your state into small atomic pieces. It's like Lego blocks for your app's data, where you can combine small pieces to build bigger things.
It's perfect for those who find Redux too complicated. It works great with React's concurrent features and has a very simple API that feels natural with React hooks.
State ManagementA battle-tested library that makes state management simple and scalable. It uses observable patterns to automatically track and update your app's state.
It's simpler than Redux but just as powerful. Changes to state are automatically reflected in your app without manual updates, which means less code to write and maintain.
State ManagementOfficial React bindings for Redux. Performant and flexible.
The recommended way to start new apps with React and Redux is by using our official Redux+TS template for Vite, or by creating a new Next.js project using Next's with-redux
template.
Both of these already have Redux Toolkit and React-Redux configured appropriately for that build tool, and come with a small example app that demonstrates how to use several of Redux Toolkit's features.
# Vite with our Redux+TS template # (using the `degit` tool to clone and extract the template) npx degit reduxjs/redux-templates/packages/vite-template-redux my-app # Next.js using the `with-redux` template npx create-next-app --example with-redux my-app
React Redux 8.0 requires React 16.8.3 or later (or React Native 0.59 or later).
To use React Redux with your React app, install it as a dependency:
# If you use npm: npm install react-redux # Or if you use Yarn: yarn add react-redux
You'll also need to install Redux and set up a Redux store in your app.
This assumes that you’re using npm package manager with a module bundler like Webpack or Browserify to consume CommonJS modules.
If you don’t yet use npm or a modern module bundler, and would rather prefer a single-file UMD build that makes ReactRedux
available as a global object, you can grab a pre-built version from cdnjs. We don’t recommend this approach for any serious application, as most of the libraries complementary to Redux are only available on npm.
The React Redux docs are published at https://react-redux.js.org .
The post The History and Implementation of React-Redux explains what it does, how it works, and how the API and implementation have evolved over time.
There's also a Deep Dive into React-Redux talk that covers some of the same material at a higher level.
Magick is a cutting-edge toolkit for a new kind of AI builder. Make Magick with us!
Mind-mapping software that helps writers collect and organize their knowledge, develop their ideas. Built with React, Redux, Node.js, hosted on Digital Ocean.
✍️ 个人技术博客
Respectfully opinionated convention-driven framework for building React applications. Built on React, Webpack, Redux, and React Router.
Mobile MVP Toolkit