githubEdit

getting-started

import LiteYouTubeEmbed from ‘react-lite-youtube-embed’; import ‘react-lite-youtube-embed/dist/LiteYouTubeEmbed.css’

Getting Started with React Redux

React Reduxarrow-up-right is the official Reactarrow-up-right UI bindings layer for Reduxarrow-up-right. It lets your React components read data from a Redux store, and dispatch actions to the store to update state.

Installation

React Redux 7.1+ requires React 16.8.3 or later, in order to make use of React Hooks.

Using Create React App

The recommended way to start new apps with React and Redux is by using the official Redux+JS templatearrow-up-right or Redux+TS templatearrow-up-right for Create React Apparrow-up-right, which takes advantage of Redux Toolkitarrow-up-right and React Redux’s integration with React components.

# Redux + Plain JS template
npx create-react-app my-app --template redux

# Redux + TypeScript template
npx create-react-app my-app --template redux-typescript

An Existing React App

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 Reduxarrow-up-right and set up a Redux storearrow-up-right in your app.

If you are using TypeScript, the React Redux types are maintained separately in DefinitelyTyped, but included as a dependency of the react-redux package, so they should be installed automatically. If you still need to install them manually, run:

API Overview

Provider

React Redux includes a <Provider /> component, which makes the Redux store available to the rest of your app:

Hooks

React Redux provides a pair of custom React hooks that allow your React components to interact with the Redux store.

useSelector reads a value from the store state and subscribes to updates, while useDispatch returns the store’s dispatch method to let you dispatch actions.

Learning React Redux

Learn Modern Redux Livestream

Redux maintainer Mark Erikson appeared on the “Learn with Jason” show to explain how we recommend using Redux today. The show includes a live-coded example app that shows how to use Redux Toolkit and React-Redux hooks with Typescript, as well as the new RTK Query data fetching APIs.

See the “Learn Modern Redux” show notes pagearrow-up-right for a transcript and links to the example app source.

Help and Discussion

The #redux channelarrow-up-right of the Reactiflux Discord communityarrow-up-right is our official resource for all questions related to learning and using Redux. Reactiflux is a great place to hang out, ask questions, and learn - come join us!

You can also ask questions on Stack Overflowarrow-up-right using the #redux tagarrow-up-right.

Docs Translations

Last updated

Was this helpful?