@@ -133,7 +133,7 @@ You can always write a function that generates an action creator:
133
133
``` js
134
134
function makeActionCreator (type , ... argNames ) {
135
135
return function (... args ) {
136
- let action = { type }
136
+ const action = { type }
137
137
argNames .forEach ((arg , index ) => {
138
138
action[argNames[index]] = args[index]
139
139
})
@@ -198,7 +198,7 @@ import {
198
198
class Posts extends Component {
199
199
loadData (userId ) {
200
200
// Injected into props by React Redux `connect()` call:
201
- let { dispatch, posts } = this .props
201
+ const { dispatch , posts } = this .props
202
202
203
203
if (posts[userId]) {
204
204
// There is cached data! Don't do anything.
@@ -231,7 +231,7 @@ class Posts extends Component {
231
231
return < p> Loading... < / p>
232
232
}
233
233
234
- let posts = this .props .posts .map (post =>
234
+ const posts = this .props .posts .map (post =>
235
235
< Post post= {post} key= {post .id } / >
236
236
)
237
237
@@ -262,7 +262,7 @@ Consider the code above rewritten with [redux-thunk](https://github.com/gaearon/
262
262
export function loadPosts (userId ) {
263
263
// Interpreted by the thunk middleware:
264
264
return function (dispatch , getState ) {
265
- let { posts } = getState ()
265
+ const { posts } = getState ()
266
266
if (posts[userId]) {
267
267
// There is cached data! Don't do anything.
268
268
return
@@ -315,7 +315,7 @@ class Posts extends Component {
315
315
return < p> Loading... < / p>
316
316
}
317
317
318
- let posts = this .props .posts .map (post =>
318
+ const posts = this .props .posts .map (post =>
319
319
< Post post= {post} key= {post .id } / >
320
320
)
321
321
@@ -461,7 +461,7 @@ Redux reduces the boilerplate of Flux stores considerably by describing the upda
461
461
Consider this Flux store:
462
462
463
463
``` js
464
- let _todos = []
464
+ const _todos = []
465
465
466
466
const TodoStore = Object .assign ({}, EventEmitter .prototype , {
467
467
getAll () {
@@ -472,7 +472,7 @@ const TodoStore = Object.assign({}, EventEmitter.prototype, {
472
472
AppDispatcher .register (function (action ) {
473
473
switch (action .type ) {
474
474
case ActionTypes .ADD_TODO :
475
- let text = action .text .trim ()
475
+ const text = action .text .trim ()
476
476
_todos .push (text)
477
477
TodoStore .emitChange ()
478
478
}
@@ -487,7 +487,7 @@ With Redux, the same update logic can be described as a reducing function:
487
487
export function todos (state = [], action ) {
488
488
switch (action .type ) {
489
489
case ActionTypes .ADD_TODO :
490
- let text = action .text .trim ()
490
+ const text = action .text .trim ()
491
491
return [... state, text]
492
492
default :
493
493
return state
@@ -506,7 +506,7 @@ Let's write a function that lets us express reducers as an object mapping from a
506
506
``` js
507
507
export const todos = createReducer ([], {
508
508
[ActionTypes .ADD_TODO ]: (state , action ) => {
509
- let text = action .text .trim ()
509
+ const text = action .text .trim ()
510
510
return [... state, text]
511
511
}
512
512
})
0 commit comments