Skip to content

Instantly share code, notes, and snippets.

@vzaidman
Created December 8, 2017 13:00
Show Gist options
  • Save vzaidman/6fd7e79c9900bf44b2e625f2e57e9dd9 to your computer and use it in GitHub Desktop.
Save vzaidman/6fd7e79c9900bf44b2e625f2e57e9dd9 to your computer and use it in GitHub Desktop.
// redux-toolbelt action creator is imported directly to the reducer
import {increaseBy} from './actions'
export default countReducer = (state = deafaultState, {payload, type}) => {
switch(type){
// the action creator is used inside the reducer to get it's type
case increaseBy.TYPE:
return {
...state,
count: state.count + payload
}
default:
return state
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment