state不变性的一些细节,但是,这里是对你到目前为止学到的所有内容的回顾。
incAction和decActio action creator counterReducer(),INCREMENT和DECREMENT action 类型,最后是 Redux store。一旦完成,你应该能够 dispatch INCREMENT或DECREMENT动作来增加或减少store中保存的状态。开始构建你的第一个 Redux 应用程序吧,祝你好运!
incAction应返回一个 action 对象 {type:"INCREMENT"}。'
testString: assert(incAction().type ===INCREMENT);
- text: 'action creator decAction应返回一个 action 对象 {type:"DECREMENT"}。'
testString: assert(decAction().type === DECREMENT);
- text: Redux store 应该将state初始化为 0。
testString: assert(store.getState() === 0);
- text: 在 Redux store 上 dispatch incAction应该将state增加 1。
testString: assert((function() { const initialState = store.getState(); store.dispatch(incAction()); const incState = store.getState(); return initialState + 1 === incState })());
- text: 在 Redux store 上 dispatch decAction应该将state减少 1。
testString: assert((function() { const initialState = store.getState(); store.dispatch(decAction()); const decState = store.getState(); return initialState - 1 === decState })());
- text: counterReducer必须是一个函数。
testString: assert(typeof counterReducer === 'function');
```