You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-2Lines changed: 20 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,12 +11,30 @@ Performant and flexible.
11
11
12
12
## Installation
13
13
14
-
React Redux requires **React 16.8.3 or later.**
14
+
### Using Create React App
15
15
16
+
The recommended way to start new apps with React Redux is by using the [official Redux+JS template](https://github.com/reduxjs/cra-template-redux) for [Create React App](https://github.com/facebook/create-react-app), which takes advantage of [Redux Toolkit](https://redux-toolkit.js.org/).
17
+
18
+
```sh
19
+
npx create-react-app my-app --template redux
16
20
```
17
-
npm install --save react-redux
21
+
22
+
### An Existing React App
23
+
24
+
React Redux 7.1 requires **React 16.8.3 or later.**
25
+
26
+
To use React Redux with your React app, install it as a dependency:
27
+
28
+
```bash
29
+
# If you use npm:
30
+
npm install react-redux
31
+
32
+
# Or if you use Yarn:
33
+
yarn add react-redux
18
34
```
19
35
36
+
You'll also need to [install Redux](https://redux.js.org/introduction/installation) and [set up a Redux store](https://redux.js.org/recipes/configuring-your-store/) in your app.
37
+
20
38
This assumes that you’re using [npm](http://npmjs.com/) package manager
21
39
with a module bundler like [Webpack](https://webpack.js.org/) or
22
40
[Browserify](http://browserify.org/) to consume [CommonJS
The number of declared function parameters of `mapDispatchToProps` determines whether they receive ownProps. See notes [here](#the-arity-of-maptoprops-functions).
We recommend encapsulating any complex lookups or computations of data in selector functions. In addition, you can further optimize the performance by using [Reselect](https://github.com/reduxjs/reselect) to write “memoized” selectors that can skip unnecessary work. (See [the Redux docs page on Computing Derived Data](https://redux.js.org/recipes/computingderiveddata#sharing-selectors-across-multiple-components) and the blog post [Idiomatic Redux: Using Reselect Selectors for Encapsulation and Performance](https://blog.isquaredsoftware.com/2017/12/idiomatic-redux-using-reselect-selectors/) for more information on why and how to use selector functions.)
280
+
We recommend encapsulating any complex lookups or computations of data in selector functions. In addition, you can further optimize the performance by using [Reselect](https://github.com/reduxjs/reselect) to write “memoized” selectors that can skip unnecessary work. (See [the Redux docs page on Computing Derived Data](https://redux.js.org/recipes/computing-derived-data#sharing-selectors-across-multiple-components) and the blog post [Idiomatic Redux: Using Reselect Selectors for Encapsulation and Performance](https://blog.isquaredsoftware.com/2017/12/idiomatic-redux-using-reselect-selectors/) for more information on why and how to use selector functions.)
281
281
282
282
Now that our `<TodoList />` is connected to the store. It should receive the list of todos, map over them, and pass each todo to the `<Todo />` component. `<Todo />` will in turn render them to the screen. Now try adding a todo. It should come up on our todo list!
Copy file name to clipboardExpand all lines: docs/introduction/quick-start.md
+12-4Lines changed: 12 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,15 +13,23 @@ sidebar_label: Quick Start
13
13
14
14
React Redux 7.1 requires **React 16.8.3 or later.**
15
15
16
-
To use React Redux with your React app:
16
+
### Using Create React App
17
17
18
-
```bash
19
-
npm install react-redux
18
+
The recommended way to start new apps with React Redux is by using the [official Redux+JS template](https://github.com/reduxjs/cra-template-redux) for [Create React App](https://github.com/facebook/create-react-app), which takes advantage of [Redux Toolkit](https://redux-toolkit.js.org/).
19
+
20
+
```sh
21
+
npx create-react-app my-app --template redux
20
22
```
21
23
22
-
or
24
+
### An Existing React App
25
+
26
+
To use React Redux with your React app, install it as a dependency:
Copy file name to clipboardExpand all lines: docs/using-react-redux/accessing-store.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,10 @@ by a single default context object instance generated by `React.createContext()`
26
26
React Redux's `<Provider>` component uses `<ReactReduxContext.Provider>` to put the Redux store and the current store
27
27
state into context, and `connect` uses `<ReactReduxContext.Consumer>` to read those values and handle updates.
28
28
29
+
## Using the `useStore` Hook
30
+
31
+
The [`useStore` hook](../api/hooks.md#useStore) returns the current store instance from the default `ReactReduxContext`. If you truly need to access the store, this is the recommended approach.
32
+
29
33
## Providing Custom Context
30
34
31
35
Instead of using the default context instance from React Redux, you may supply your own custom context instance.
Copy file name to clipboardExpand all lines: website/versioned_docs/version-7.2/using-react-redux/accessing-store.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,10 @@ propagated to connected components, so that this works as expected by default.
18
18
However, there may be certain use cases where you may need to customize how the store and state are propagated to
19
19
connected components, or access the store directly. Here are some examples of how to do this.
20
20
21
+
## Using the `useStore` Hook
22
+
23
+
The [`useStore` hook](../api/hooks.md#useStore) returns the current store instance from the default `ReactReduxContext`. If you truly need to access the store, this is the recommended approach.
24
+
21
25
## Understanding Context Usage
22
26
23
27
Internally, React Redux uses [React's "context" feature](https://reactjs.org/docs/context.html) to make the
0 commit comments