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 provides a way to connect React components to a Redux store, while Redux Toolkit provides a set of tools to simplify Redux development, including a configureStore function and a createSlice function for generating reducers and actions.
Both packages support TypeScript, with react-redux requiring TypeScript 3.5 or higher and redux-toolkit requiring TypeScript 4.0 or higher.
Both packages are compatible with modern browsers, including Chrome, Firefox, Safari, and Edge.
React-Redux depends on React and Redux, while Redux Toolkit depends on Redux.
Both packages are optimized for performance, with Redux Toolkit providing additional performance optimizations through its configureStore function.
Both packages are compatible with React, with Redux Toolkit also compatible with other frameworks such as Angular and Vue.
Both packages have active communities, with react-redux having a slightly higher number of contributors and issues on GitHub.
Both packages have high-quality documentation, with Redux Toolkit providing more extensive documentation and tutorials.
Both packages are actively maintained, with regular updates and bug fixes.
1import React from 'react';
2import { connect } from 'react-redux';
3
4const MyComponent = ({ name }) => <div>Hello, {name}!</div>;
5
6const mapStateToProps = state => ({ name: state.name });
7
8export default connect(mapStateToProps)(MyComponent);
This example shows how to connect a React component to a Redux store using the connect function from react-redux.
1import { configureStore } from '@reduxjs/toolkit';
2import counterReducer from './counterReducer';
3
4const store = configureStore({ reducer: { counter: counterReducer } });
This example shows how to create a Redux store using the configureStore function from Redux Toolkit.
Both packages are suitable for building Redux applications with React, but Redux Toolkit provides additional features and optimizations that make it a better choice for most use cases.
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.
JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
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.