Skip to content

Instantly share code, notes, and snippets.

@jinook929
Created May 31, 2021 01:43
Show Gist options
  • Save jinook929/e0df4f59a7c8cd085d2f4b361f75cca4 to your computer and use it in GitHub Desktop.
Save jinook929/e0df4f59a7c8cd085d2f4b361f75cca4 to your computer and use it in GitHub Desktop.
React with Hooks, with Redux: reducer/index.js
const countReducer = (state = {count: 0}, action) => {
switch(action.type) {
case "INCREASE_COUNT":
return {...state, count: action.payload}
case "DECREASE_COUNT":
return {...state, count: action.payload}
case "RESET_COUNT":
return {...state, count: action.payload}
default:
return state
}
}
export default countReducer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment