Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply prettier to the files which cannot be parsed automatically
  • Loading branch information
CodinCat committed May 2, 2017
commit 79519c16d7d3c2e60ddaef06a340e1d0152c5128
14 changes: 7 additions & 7 deletions docs/advanced/UsageWithReactRouter.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ Before integrating React Router, we need to configure our development server. In

### Configuring Express
If you are serving your `index.html` from Express:
``` js
app.get('/*', (req,res) => {
res.sendFile(path.join(__dirname, 'index.html'))
})
```js
app.get('/*', (req, res) => {
res.sendFile(path.join(__dirname, 'index.html'))
})
```

### Configuring WebpackDevServer
If you are serving your `index.html` from WebpackDevServer:
You can add to your webpack.config.dev.js:
```js
devServer: {
historyApiFallback: true,
}
devServer: {
historyApiFallback: true
}
```

## Connecting React Router with Redux App
Expand Down
2 changes: 1 addition & 1 deletion docs/basics/ExampleTodoList.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default todoApp
#### `components/Todo.js`

```js
import React, from 'react'
import React from 'react'
import PropTypes from 'prop-types'

const Todo = ({ onClick, completed, text }) => (
Expand Down
2 changes: 1 addition & 1 deletion docs/basics/Reducers.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function todoApp(state = initialState, action) {
completed: false
}
]
})
})
default:
return state
}
Expand Down
52 changes: 32 additions & 20 deletions docs/recipes/ImplementingUndoHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ It is reasonable to suggest that our state shape should change to answer these q
```js
{
counter: {
past: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ],
past: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
present: 10,
future: []
}
Expand All @@ -56,9 +56,9 @@ Now, if user presses “Undo”, we want it to change to move into the past:
```js
{
counter: {
past: [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ],
past: [0, 1, 2, 3, 4, 5, 6, 7, 8],
present: 9,
future: [ 10 ]
future: [10]
}
}
```
Expand All @@ -68,9 +68,9 @@ And further yet:
```js
{
counter: {
past: [ 0, 1, 2, 3, 4, 5, 6, 7 ],
past: [0, 1, 2, 3, 4, 5, 6, 7],
present: 8,
future: [ 9, 10 ]
future: [9, 10]
}
}
```
Expand All @@ -80,9 +80,9 @@ When the user presses “Redo”, we want to move one step back into the future:
```js
{
counter: {
past: [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ],
past: [0, 1, 2, 3, 4, 5, 6, 7, 8],
present: 9,
future: [ 10 ]
future: [10]
}
}
```
Expand All @@ -92,7 +92,7 @@ Finally, if the user performs an action (e.g. decrement the counter) while we're
```js
{
counter: {
past: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ],
past: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
present: 8,
future: []
}
Expand All @@ -104,9 +104,9 @@ The interesting part here is that it does not matter whether we want to keep an
```js
{
counter: {
past: [ 0, 1, 2 ],
past: [0, 1, 2],
present: 3,
future: [ 4 ]
future: [4]
}
}
```
Expand All @@ -116,12 +116,18 @@ The interesting part here is that it does not matter whether we want to keep an
todos: {
past: [
[],
[ { text: 'Use Redux' } ],
[ { text: 'Use Redux', complete: true } ]
[{ text: 'Use Redux' }],
[{ text: 'Use Redux', complete: true }]
],
present: [
{ text: 'Use Redux', complete: true },
{ text: 'Implement Undo' }
],
present: [ { text: 'Use Redux', complete: true }, { text: 'Implement Undo' } ],
future: [
[ { text: 'Use Redux', complete: true }, { text: 'Implement Undo', complete: true } ]
[
{ text: 'Use Redux', complete: true },
{ text: 'Implement Undo', complete: true }
]
]
}
}
Expand Down Expand Up @@ -156,12 +162,12 @@ Or many granular histories so user can undo and redo actions in them independent
```js
{
counterA: {
past: [ 1, 0 ],
past: [1, 0],
present: 2,
future: []
},
counterB: {
past: [ 0 ],
past: [0],
present: 1,
future: []
}
Expand Down Expand Up @@ -429,12 +435,18 @@ Now the `todos` part of the state looks like this:
todos: {
past: [
[],
[ { text: 'Use Redux' } ],
[ { text: 'Use Redux', complete: true } ]
[{ text: 'Use Redux' }],
[{ text: 'Use Redux', complete: true }]
],
present: [
{ text: 'Use Redux', complete: true },
{ text: 'Implement Undo' }
],
present: [ { text: 'Use Redux', complete: true }, { text: 'Implement Undo' } ],
future: [
[ { text: 'Use Redux', complete: true }, { text: 'Implement Undo', complete: true } ]
[
{ text: 'Use Redux', complete: true },
{ text: 'Implement Undo', complete: true }
]
]
}
}
Expand Down
10 changes: 4 additions & 6 deletions docs/recipes/UsingObjectSpreadOperator.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ function todoApp(state = initialState, action) {
The advantage of using the object spread syntax becomes more apparent when you're composing complex objects. Below `getAddedIds` maps an array of `id` values to an array of objects with values returned from `getProduct` and `getQuantity`.

```js
return getAddedIds(state.cart).map(id => Object.assign(
{},
getProduct(state.products, id),
{
return getAddedIds(state.cart).map(id =>
Object.assign({}, getProduct(state.products, id), {
quantity: getQuantity(state.cart, id)
}
))
})
)
```

Object spread lets us simplify the above `map` call to:
Expand Down
2 changes: 1 addition & 1 deletion docs/recipes/WritingTests.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ npm install --save-dev jest

To use it together with [Babel](http://babeljs.io), you will need to install `babel-jest`:

```js
```
npm install --save-dev babel-jest
```

Expand Down
22 changes: 11 additions & 11 deletions docs/recipes/reducers/BasicReducerStructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ First and foremost, it's important to understand that your entire application re
- The first time the reducer is called, the `state` value will be `undefined`. The reducer needs to handle this case by supplying a default state value before handling the incoming action.
- It needs to look at the previous state and the dispatched action, and determine what kind of work needs to be done
- Assuming actual changes need to occur, it needs to create new objects and arrays with the updated data and return those
- If no changes are needed, it should return the existing state as-is.
- If no changes are needed, it should return the existing state as-is.

The simplest possible approach to writing reducer logic is to put everything into a single function declaration, like this:

Expand Down Expand Up @@ -49,7 +49,7 @@ This is the basic structure that a typical Redux reducer function uses.

Redux encourages you to think about your application in terms of the data you need to manage. The data at any given point in time is the "*state*" of your application, and the structure and organization of that state is typically referred to as its "*shape*". The shape of your state plays a major role in how you structure your reducer logic.

A Redux state usually has a plain Javascript object as the top of the state tree. (It is certainly possible to have another type of data instead, such as a single number, an array, or a specialized data structure, but most libraries assume that the top-level value is a plain object.) The most common way to organize data within that top-level object is to further divide data into sub-trees, where each top-level key represents some "domain" or "slice" of related data. For example, a basic Todo app's state might look like:
A Redux state usually has a plain Javascript object as the top of the state tree. (It is certainly possible to have another type of data instead, such as a single number, an array, or a specialized data structure, but most libraries assume that the top-level value is a plain object.) The most common way to organize data within that top-level object is to further divide data into sub-trees, where each top-level key represents some "domain" or "slice" of related data. For example, a basic Todo app's state might look like:

```js
{
Expand Down Expand Up @@ -84,13 +84,13 @@ A typical app's state shape might look roughly like:

```js
{
domainData1 : {},
domainData2 : {},
appState1 : {},
appState2 : {},
ui : {
uiState1 : {},
uiState2 : {},
}
domainData1: {},
domainData2: {},
appState1: {},
appState2: {},
ui: {
uiState1: {},
uiState2: {}
}
}
```
```
Loading