Created
October 7, 2017 18:50
-
-
Save vzaidman/f927ba1c5905c4a0993d3db0a6723b93 to your computer and use it in GitHub Desktop.
Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The action creator increaseBy is imported | |
// instead of the action's name from consts.js | |
import { increaseBy, decreaseBy } from './actions' | |
const deafaultCount = 100 | |
export default countReducer = (count = deafaultCount, { payload, type }) => { | |
switch(type){ | |
// an action creator is used inside the reducer to get it's type | |
case increaseBy.TYPE: { | |
return count + payload | |
} | |
// another action creator is used inside the reducer to get it's type | |
case decreaseBy.TYPE: { | |
return count - payload | |
} | |
default: { | |
return count | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment