Skip to content

Commit 88bf6b9

Browse files
committed
Reformat, again
1 parent b23997a commit 88bf6b9

File tree

2 files changed

+54
-51
lines changed

2 files changed

+54
-51
lines changed

README.md

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,46 @@
1-
# Redux Starter Kit
2-
3-
[![build status](https://img.shields.io/travis/reduxjs/redux-starter-kit/master.svg?style=flat-square)](https://travis-ci.org/reduxjs/redux-starter-kit)
4-
[![npm version](https://img.shields.io/npm/v/redux-starter-kit.svg?style=flat-square)](https://www.npmjs.com/package/redux-starter-kit)
5-
[![npm downloads](https://img.shields.io/npm/dm/redux-starter-kit.svg?style=flat-square)](https://www.npmjs.com/package/redux-starter-kit)
6-
7-
**A simple set of tools to make using Redux easier**
8-
9-
`npm install redux-starter-kit`
10-
11-
(Special thanks to Github user @shotak for donating to the package name.)
12-
13-
### Purpose
14-
15-
The `redux-starter-kit` package is intended to help address three common complaints about Redux:
16-
17-
- "Configuring a Redux store is too complicated"
18-
- "I have to add a lot of packages to get Redux to do anything useful"
19-
- "Redux requires too much boilerplate code"
20-
21-
We can't solve every use case, but in the spirit of [`create-react-app`](https://github.com/facebook/create-react-app) and [`apollo-boost`](https://dev-blog.apollodata.com/zero-config-graphql-state-management-27b1f1b3c2c3), we can try to provide some tools that abstract over the setup process and handle the most common use cases, as well as include some useful utilities that will let the user simplify their application code.
22-
23-
This package is _not_ intended to solve every possible complaint about 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.
24-
25-
### What's Included
26-
27-
`redux-starter-kit` includes:
28-
29-
- A `configureStore()` function with simplified configuration options. It can automatically combine your slice reducers, adds whatever Redux middleware you supply, includes `redux-thunk` by default, and enables use of the Redux DevTools Extension.
30-
- A `createReducer()` utility that lets you supply a lookup table of action types to case reducer functions, rather than writing switch statements. In addition, it automatically uses the [`immer` library](https://github.com/mweststrate/immer) to let you write simpler immutable updates with normal mutative code, like `state.todos[3].completed = true`.
31-
- A `createAction()` utility that returns an action creator function for the given action type string. The function itself has `toString()` defined, so that it can be used in place of the type constant.
32-
- A `createSlice()` function that accepts a set of reducer functions, a slice name, and an initial state value, and automatically generates corresponding action creators, types, and simple selector functions.
33-
- An improved version of the widely used `createSelector` utility for creating memoized selector functions, which can accept string keypaths as "input selectors" (re-exported from the [`selectorator` library](https://github.com/planttheidea/selectorator)).
34-
35-
## Documentation
36-
37-
The `redux-starter-kit` docs are now published at **https://redux-starter-kit.js.org**.
38-
39-
We're currently expanding and rewriting our docs content - check back soon for more updates!
1+
# Redux Starter Kit
2+
3+
[![build status](https://img.shields.io/travis/reduxjs/redux-starter-kit/master.svg?style=flat-square)](https://travis-ci.org/reduxjs/redux-starter-kit)
4+
5+
[![npm version](https://img.shields.io/npm/v/redux-starter-kit.svg?style=flat-square)](https://www.npmjs.com/package/redux-starter-kit)
6+
7+
**A simple set of tools to make using Redux easier**
8+
9+
`npm install redux-starter-kit`
10+
11+
(Special thanks to Github user @shotak for dona
12+
13+
**A simple set of tools to make using Redux easier**
14+
15+
`npm install redux-starter-kit`
16+
17+
(Special thanks to Github user @shotak for donating to the package name.)
18+
19+
### Purpose
20+
21+
The `redux-starter-kit` package is intended to help address three common complaints about Redux:
22+
23+
- "Configuring a Redux store is too complicated"
24+
- "I have to add a lot of packages to get Redux to do anything useful"
25+
- "Redux requires too much boilerplate code"
26+
27+
We can't solve every use case, but in the spirit of le complaint about Redux, and is deliberately limited in scope. It and _not_ address concepts like "reusable encapsulated Redux modules", data fetching, folder or file s, we can try to provide some tools that abstract over the setup process and handle the most common use cases, as well as include some useful utilities that will let the user simplify their application code.
28+
29+
This package is _not_ intended to solve every possible complaint about 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.
30+
31+
### What's Included
32+
33+
`redux-starter-kit` includes:
34+
35+
- A `configureStore()` function with simplified configuration options. It can automatically combine your slice reducers, adds whatever Redux middleware you supply, includes `redux-thunk` by default, and enables use of the Redux DevTools Extension.
36+
- A `createReducer()` utility that lets you supply a lookup table of action types to case reducer functions, rather than writing switch statements. In addition, it automatically uses the e selector functions.
37+
- An improved version of the wid to let you write simpler immutable updates with normal mutative code, like `state.todos[3].completed = true`.
38+
- A `createAction()` utility that returns an action creator function for the given action type string. The function itself has `toString()` defined, so that it can be used in place of the type constant.
39+
- A `createSlice()` function that accepts a set of reducer functions, a slice name, and an initial state value, and automatically generates corresponding action creators, types, and simple selector functions.
40+
- An improved version of the widely used `createSelector` utility for creating memoized selector functions, which can accept string keypaths as "input selectors" (re-exported from the n for more updates!).
41+
42+
## Documentation
43+
44+
The `redux-starter-kit` docs are now published at **tent - check back soon for more **.
45+
46+
We're currently expanding and rewriting our docs content - check back soon for more updates!

docs/api/createReducer.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ hide_title: true
77

88
# `createReducer()`
99

10-
A utility that simplifies creating Redux reducer functions, by defining them as lookup tables of functions to handle each action type. It also allows you to drastically simplify immutable update logic, by writing "mutative" code inside your reducers.
10+
A utility that simplifies creating Redux reducer functions, by defining them as lookup tables of functions to handle each action type. It also allows you to drastically simplify immutable update logic, by writing "mutative" code inside your reducers.
1111

1212
Redux [reducers](https://redux.js.org/basics/reducers) are often implemented using a `switch` statement, with one `case` for every handled action type.
1313

@@ -49,7 +49,7 @@ const counterReducer = createReducer(0, {
4949

5050
## Direct State Mutation
5151

52-
Redux requires reducer functions to be pure and treat state values as immutable. While this is essential for making state updates predictable and observable, it can sometimes make the implementation of such updates awkward. Consider the following example:
52+
Redux requires reducer functions to be pure and treat state values as immutable. While this is essential for making state updates predictable and observable, it can sometimes make the implementation of such updates awkward. Consider the following example:
5353

5454
```js
5555
const addTodo = createAction('todos/add')
@@ -72,7 +72,7 @@ const todosReducer = createReducer([], {
7272
})
7373
```
7474

75-
The `addTodo` reducer is pretty easy to follow if you know the [ES6 spread syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax). However, the code for `toggleTodo` is much less straightforward, especially considering that it only sets a single flag.
75+
The `addTodo` reducer is pretty easy to follow if you know the [ES6 spread syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax). However, the code for `toggleTodo` is much less straightforward, especially considering that it only sets a single flag.
7676

7777
To make things easier, `createReducer` uses [immer](https://github.com/mweststrate/immer) to let you write reducers as if they were mutating the state directly. In reality, the reducer receives a proxy state that translates all mutations into equivalent copy operations.
7878

@@ -84,19 +84,19 @@ const todosReducer = createReducer([], {
8484
[addTodo]: (state, action) => {
8585
// This push() operation gets translated into the same
8686
// extended-array creation as in the previous example.
87-
state.push(todo)
87+
state.push(todo)
8888
},
8989
[toggleTodo]: (state, action) => {
9090
// The "mutating" version of this case reducer is much
9191
// more direct than the explicitly pure one.
9292
const index = action.payload
93-
const todo = state[index]
94-
todo.completed = !todo.completed
93+
const todo = state[index]
94+
todo.completed = !todo.completed
9595
}
9696
})
9797
```
9898

99-
If you choose to write reducers in this style, make sure to learn about the [pitfalls mentioned in the immer docs](https://github.com/mweststrate/immer#pitfalls) . Most importantly, you need to ensure that you either mutate the `state` argument or return a new state, _but not both_. For example, the following reducer would throw an exception if a `toggleTodo` action is passed:
99+
If you choose to write reducers in this style, make sure to learn about the [pitfalls mentioned in the immer docs](https://github.com/mweststrate/immer#pitfalls) . Most importantly, you need to ensure that you either mutate the `state` argument or return a new state, _but not both_. For example, the following reducer would throw an exception if a `toggleTodo` action is passed:
100100

101101
```js
102102
const todosReducer = createReducer([], {
@@ -110,11 +110,7 @@ const todosReducer = createReducer([], {
110110
// ... and returns a new value. This will throw an
111111
// exception. In this example, the easiest fix is
112112
// to remove the `return` statement.
113-
return [
114-
...state.slice(0, index),
115-
todo,
116-
...state.slice(index + 1)
117-
]
113+
return [...state.slice(0, index), todo, ...state.slice(index + 1)]
118114
}
119115
})
120116
```

0 commit comments

Comments
 (0)