state
immutability, but first, here's a review of everything you've learned so far.
incAction
and decAction
action creators, the counterReducer()
, INCREMENT
and DECREMENT
action types, and finally the Redux store
. Once you're finished you should be able to dispatch INCREMENT
or DECREMENT
actions to increment or decrement the state held in the store
. Good luck building your first Redux app!
incAction
should return an action object with type
equal to the value of INCREMENT
testString: 'assert(incAction().type ===INCREMENT, "The action creator incAction
should return an action object with type
equal to the value of INCREMENT
");'
- text: The action creator decAction
should return an action object with type
equal to the value of DECREMENT
testString: 'assert(decAction().type === DECREMENT, "The action creator decAction
should return an action object with type
equal to the value of DECREMENT
");'
- text: The Redux store should initialize with a state
of 0.
testString: 'assert(store.getState() === 0, "The Redux store should initialize with a state
of 0.");'
- text: Dispatching incAction
on the Redux store should increment the state
by 1.
testString: 'assert((function() { const initialState = store.getState(); store.dispatch(incAction()); const incState = store.getState(); return initialState + 1 === incState })(), "Dispatching incAction
on the Redux store should increment the state
by 1.");'
- text: Dispatching decAction
on the Redux store should decrement the state
by 1.
testString: 'assert((function() { const initialState = store.getState(); store.dispatch(decAction()); const decState = store.getState(); return initialState - 1 === decState })(), "Dispatching decAction
on the Redux store should decrement the state
by 1.");'
- text: counterReducer
should be a function
testString: 'assert(typeof counterReducer === "function", "counterReducer
should be a function");'
```