Skip to content

Commit 6e53b1e

Browse files
committed
Format all the things!
1 parent d0106e1 commit 6e53b1e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+732
-849
lines changed

docs/Troubleshooting.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function todos(state = [], action) {
3131
// Wrong! This mutates state
3232
state.push({
3333
text: action.text,
34-
completed: false
34+
completed: false,
3535
})
3636
return state
3737
case 'COMPLETE_TODO':
@@ -55,16 +55,16 @@ function todos(state = [], action) {
5555
...state,
5656
{
5757
text: action.text,
58-
completed: false
59-
}
58+
completed: false,
59+
},
6060
]
6161
case 'COMPLETE_TODO':
6262
// Return a new array
6363
return state.map((todo, index) => {
6464
if (index === action.index) {
6565
// Copy the object before mutating
6666
return Object.assign({}, todo, {
67-
completed: true
67+
completed: true,
6868
})
6969
}
7070
return todo
@@ -82,7 +82,7 @@ It's more code, but it's exactly what makes Redux predictable and efficient. If
8282
return state.map((todo, index) => {
8383
if (index === action.index) {
8484
return Object.assign({}, todo, {
85-
completed: true
85+
completed: true,
8686
})
8787
}
8888
return todo
@@ -92,9 +92,9 @@ return state.map((todo, index) => {
9292
return update(state, {
9393
[action.index]: {
9494
completed: {
95-
$set: true
96-
}
97-
}
95+
$set: true,
96+
},
97+
},
9898
})
9999
```
100100

@@ -109,7 +109,7 @@ You can also enable the [object spread operator proposal](recipes/UsingObjectSpr
109109
return state.map((todo, index) => {
110110
if (index === action.index) {
111111
return Object.assign({}, todo, {
112-
completed: true
112+
completed: true,
113113
})
114114
}
115115
return todo

docs/advanced/AsyncActions.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const SELECT_SUBREDDIT = 'SELECT_SUBREDDIT'
6262
export function selectSubreddit(subreddit) {
6363
return {
6464
type: SELECT_SUBREDDIT,
65-
subreddit
65+
subreddit,
6666
}
6767
}
6868
```
@@ -75,7 +75,7 @@ export const INVALIDATE_SUBREDDIT = 'INVALIDATE_SUBREDDIT'
7575
export function invalidateSubreddit(subreddit) {
7676
return {
7777
type: INVALIDATE_SUBREDDIT,
78-
subreddit
78+
subreddit,
7979
}
8080
}
8181
```
@@ -90,7 +90,7 @@ export const REQUEST_POSTS = 'REQUEST_POSTS'
9090
function requestPosts(subreddit) {
9191
return {
9292
type: REQUEST_POSTS,
93-
subreddit
93+
subreddit,
9494
}
9595
}
9696
```
@@ -106,8 +106,8 @@ function receivePosts(subreddit, json) {
106106
return {
107107
type: RECEIVE_POSTS,
108108
subreddit,
109-
posts: json.data.children.map(child => child.data),
110-
receivedAt: Date.now()
109+
posts: json.data.children.map((child) => child.data),
110+
receivedAt: Date.now(),
111111
}
112112
}
113113
```
@@ -225,7 +225,7 @@ import {
225225
SELECT_SUBREDDIT,
226226
INVALIDATE_SUBREDDIT,
227227
REQUEST_POSTS,
228-
RECEIVE_POSTS
228+
RECEIVE_POSTS,
229229
} from '../actions'
230230
231231
function selectedSubreddit(state = 'reactjs', action) {
@@ -241,26 +241,26 @@ function posts(
241241
state = {
242242
isFetching: false,
243243
didInvalidate: false,
244-
items: []
244+
items: [],
245245
},
246246
action
247247
) {
248248
switch (action.type) {
249249
case INVALIDATE_SUBREDDIT:
250250
return Object.assign({}, state, {
251-
didInvalidate: true
251+
didInvalidate: true,
252252
})
253253
case REQUEST_POSTS:
254254
return Object.assign({}, state, {
255255
isFetching: true,
256-
didInvalidate: false
256+
didInvalidate: false,
257257
})
258258
case RECEIVE_POSTS:
259259
return Object.assign({}, state, {
260260
isFetching: false,
261261
didInvalidate: false,
262262
items: action.posts,
263-
lastUpdated: action.receivedAt
263+
lastUpdated: action.receivedAt,
264264
})
265265
default:
266266
return state
@@ -273,7 +273,7 @@ function postsBySubreddit(state = {}, action) {
273273
case RECEIVE_POSTS:
274274
case REQUEST_POSTS:
275275
return Object.assign({}, state, {
276-
[action.subreddit]: posts(state[action.subreddit], action)
276+
[action.subreddit]: posts(state[action.subreddit], action),
277277
})
278278
default:
279279
return state
@@ -282,7 +282,7 @@ function postsBySubreddit(state = {}, action) {
282282
283283
const rootReducer = combineReducers({
284284
postsBySubreddit,
285-
selectedSubreddit
285+
selectedSubreddit,
286286
})
287287
288288
export default rootReducer
@@ -294,7 +294,7 @@ In this code, there are two interesting parts:
294294

295295
```js
296296
return Object.assign({}, state, {
297-
[action.subreddit]: posts(state[action.subreddit], action)
297+
[action.subreddit]: posts(state[action.subreddit], action),
298298
})
299299
```
300300

@@ -327,7 +327,7 @@ export const REQUEST_POSTS = 'REQUEST_POSTS'
327327
function requestPosts(subreddit) {
328328
return {
329329
type: REQUEST_POSTS,
330-
subreddit
330+
subreddit,
331331
}
332332
}
333333

@@ -336,16 +336,16 @@ function receivePosts(subreddit, json) {
336336
return {
337337
type: RECEIVE_POSTS,
338338
subreddit,
339-
posts: json.data.children.map(child => child.data),
340-
receivedAt: Date.now()
339+
posts: json.data.children.map((child) => child.data),
340+
receivedAt: Date.now(),
341341
}
342342
}
343343

344344
export const INVALIDATE_SUBREDDIT = 'INVALIDATE_SUBREDDIT'
345345
export function invalidateSubreddit(subreddit) {
346346
return {
347347
type: INVALIDATE_SUBREDDIT,
348-
subreddit
348+
subreddit,
349349
}
350350
}
351351

@@ -358,7 +358,7 @@ export function fetchPosts(subreddit) {
358358
// It passes the dispatch method as an argument to the function,
359359
// thus making it able to dispatch actions itself.
360360

361-
return function(dispatch) {
361+
return function (dispatch) {
362362
// First dispatch: the app state is updated to inform
363363
// that the API call is starting.
364364

@@ -372,14 +372,14 @@ export function fetchPosts(subreddit) {
372372

373373
return fetch(`https://www.reddit.com/r/${subreddit}.json`)
374374
.then(
375-
response => response.json(),
375+
(response) => response.json(),
376376
// Do not use catch, because that will also catch
377377
// any errors in the dispatch and resulting render,
378378
// causing a loop of 'Unexpected batch number' errors.
379379
// https://github.com/facebook/react/issues/6895
380-
error => console.log('An error occurred.', error)
380+
(error) => console.log('An error occurred.', error)
381381
)
382-
.then(json =>
382+
.then((json) =>
383383
// We can dispatch many times!
384384
// Here, we update the app state with the results of the API call.
385385

@@ -443,7 +443,7 @@ export const REQUEST_POSTS = 'REQUEST_POSTS'
443443
function requestPosts(subreddit) {
444444
return {
445445
type: REQUEST_POSTS,
446-
subreddit
446+
subreddit,
447447
}
448448
}
449449

@@ -452,25 +452,25 @@ function receivePosts(subreddit, json) {
452452
return {
453453
type: RECEIVE_POSTS,
454454
subreddit,
455-
posts: json.data.children.map(child => child.data),
456-
receivedAt: Date.now()
455+
posts: json.data.children.map((child) => child.data),
456+
receivedAt: Date.now(),
457457
}
458458
}
459459

460460
export const INVALIDATE_SUBREDDIT = 'INVALIDATE_SUBREDDIT'
461461
export function invalidateSubreddit(subreddit) {
462462
return {
463463
type: INVALIDATE_SUBREDDIT,
464-
subreddit
464+
subreddit,
465465
}
466466
}
467467

468468
function fetchPosts(subreddit) {
469-
return dispatch => {
469+
return (dispatch) => {
470470
dispatch(requestPosts(subreddit))
471471
return fetch(`https://www.reddit.com/r/${subreddit}.json`)
472-
.then(response => response.json())
473-
.then(json => dispatch(receivePosts(subreddit, json)))
472+
.then((response) => response.json())
473+
.then((json) => dispatch(receivePosts(subreddit, json)))
474474
}
475475
}
476476

0 commit comments

Comments
 (0)