Last active
October 7, 2017 18:40
-
-
Save vzaidman/adceb9eae6425190b0d147e6b54bc14a to your computer and use it in GitHub Desktop.
The Vanilla Redux Way
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
const INCREASE_BY = 'INCREASE_BY' | |
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
import { INCREASE_BY } from './consts' | |
export const increaseBy = amount => ({ | |
type: INCREASE_BY, | |
payload: amount | |
}) | |
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
import { INCREASE_BY } from './consts' | |
import { increaseBy } from './actions' | |
const defaultState = 100 | |
export default countReducer = (state = defaultState, action) => { | |
const { payload, type } = action | |
switch(type){ | |
case INCREASE_BY: | |
return state + payload | |
default: | |
return state | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment