Skip to content

Instantly share code, notes, and snippets.

@vzaidman
Last active October 7, 2017 18:40
Show Gist options
  • Save vzaidman/adceb9eae6425190b0d147e6b54bc14a to your computer and use it in GitHub Desktop.
Save vzaidman/adceb9eae6425190b0d147e6b54bc14a to your computer and use it in GitHub Desktop.
The Vanilla Redux Way
const INCREASE_BY = 'INCREASE_BY'
import { INCREASE_BY } from './consts'
export const increaseBy = amount => ({
type: INCREASE_BY,
payload: amount
})
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