Skip to content

Commit 5fea69c

Browse files
committed
Merge branch 'master' into v1.3.0-integration
2 parents 3025d77 + de26824 commit 5fea69c

File tree

6 files changed

+42
-9
lines changed

6 files changed

+42
-9
lines changed

README.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,34 @@
77

88
**The official, opinionated, batteries-included toolset for efficient Redux development**
99

10-
`npm install @reduxjs/toolkit`
11-
1210
(Formerly known as "Redux Starter Kit")
1311

14-
### Purpose
12+
## Installation
13+
14+
### Using Create React App
15+
16+
The recommended way to start new apps with React and Redux Toolkit 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 React Redux's integration with React components.
17+
18+
```sh
19+
npx create-react-app my-app --template redux
20+
```
21+
22+
### An Existing App
23+
24+
Redux Toolkit is available as a package on NPM for use with a module bundler or in a Node application:
25+
26+
```bash
27+
# NPM
28+
npm install @reduxjs/toolkit
29+
30+
# Yarn
31+
yarn add @reduxjs/toolkit
32+
```
33+
34+
It is also available as a precompiled UMD package that defines a `window.RTK` global variable.
35+
The UMD package can be used as a [`<script>` tag](https://unpkg.com/@reduxjs/toolkit/dist/redux-toolkit.umd.js) directly.
36+
37+
## Purpose
1538

1639
The **Redux Toolkit** package is intended to be the standard way to write Redux logic. It was originally created to help address three common concerns about Redux:
1740

@@ -23,7 +46,7 @@ We can't solve every use case, but in the spirit of [`create-react-app`](https:/
2346

2447
This package is _not_ intended to solve every possible use case for Redux, and is deliberately limited in scope. It does _not_ address concepts like "reusable encapsulated Redux modules", data fetching, folder or file structures, managing entity relationships in the store, and so on.
2548

26-
### What's Included
49+
## What's Included
2750

2851
Redux Toolkit includes:
2952

docs/introduction/quick-start.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ Redux Toolkit includes:
3535

3636
## Installation
3737

38+
### Using Create React App
39+
40+
The recommended way to start new apps with React and Redux Toolkit 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 React Redux's integration with React components.
41+
42+
```sh
43+
npx create-react-app my-app --template redux
44+
```
45+
46+
### An Existing App
47+
3848
Redux Toolkit is available as a package on NPM for use with a module bundler or in a Node application:
3949

4050
```bash

docs/tutorials/basic-tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ document.getElementById('increment').addEventListener('click', () => {
8080
})
8181
```
8282

83-
Since the example is small, that doesn't make too much of a difference in appearance. Size-wise, we saved a couple lines by using a default argument, but writing those action creator functions made things bigger. And, there's some duplication here. Writing `const INCREMENT = 'INCREMENT"` just looks silly :) Especially when it's only being used in two places - the action creator and the reducer.
83+
Since the example is small, that doesn't make too much of a difference in appearance. Size-wise, we saved a couple lines by using a default argument, but writing those action creator functions made things bigger. And, there's some duplication here. Writing `const INCREMENT = 'INCREMENT'` just looks silly :) Especially when it's only being used in two places - the action creator and the reducer.
8484

8585
In addition, switch statements bother many people. It would be nice if we could replace it with some kind of a lookup table instead.
8686

docs/tutorials/intermediate-tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ The first step is to copy `reducers/todos.spec.js` over to `features/todos/todos
260260
261261
Once that is done, we need to update the tests to match how RTK works.
262262

263-
The first issue is that the test file hardcodes action types like `'ADD_TODO"`. RTK's action types look like `'todos/addTodo'`. We can reference that by also importing the action creators from the todos slice, and replacing the original type constants in the test with `addTodo.type`.
263+
The first issue is that the test file hardcodes action types like `'ADD_TODO'`. RTK's action types look like `'todos/addTodo'`. We can reference that by also importing the action creators from the todos slice, and replacing the original type constants in the test with `addTodo.type`.
264264

265265
The other problem is that the action objects in the tests look like `{type, id, text}`, whereas RTK always puts those extra values inside `action.payload`. So, we need to modify the test actions to match that.
266266

@@ -391,7 +391,7 @@ While we could have kept the imported function named as `todos` so that we can u
391391
392392
If we reload the app, we should still see that `state.todos` is an empty array. But, if we click on "Add Todo", nothing will happen. We're still dispatching actions whose type is `'ADD_TODO'`, while our todos slice is looking for an action type of `'todos/addTodo'`. We need to import the correct action creator and use it in the `AddTodo.js` file.
393393
394-
While we're at it, there's a couple other problems with how the `AddTodo` component is written. First, it's currently using a React "callback ref" to read the current text value from the input when you click "Add Todo". This works, but the standard "React way" to handle form fields is with the "controlled inputs" pattern, where the current field value is stored in the component's state.
394+
While we're at it, there are a couple of other problems with how the `AddTodo` component is written. First, it's currently using a React "callback ref" to read the current text value from the input when you click "Add Todo". This works, but the standard "React way" to handle form fields is with the "controlled inputs" pattern, where the current field value is stored in the component's state.
395395
396396
Second, the connected component is getting `dispatch` as a prop. Again, this works, but the normal way to use connect is to [pass action creator functions to `connect`](https://react-redux.js.org/using-react-redux/connect-mapdispatch), and then dispatch the actions by calling the functions that were passed in as props.
397397

netlify.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build]
22
base = "website"
3-
publish = "website/build"
3+
publish = "build"
44
command = "npm run build"
55

66
[build.environment]

src/createSlice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
import { Omit } from './tsHelpers'
1616

1717
/**
18-
* An action creator atttached to a slice.
18+
* An action creator attached to a slice.
1919
*
2020
* @deprecated please use PayloadActionCreator directly
2121
*

0 commit comments

Comments
 (0)