Skip to content

Instantly share code, notes, and snippets.

@pablopaul
Created November 21, 2016 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pablopaul/3c1a0d21ac466e71d9bc057ebb30550e to your computer and use it in GitHub Desktop.
Save pablopaul/3c1a0d21ac466e71d9bc057ebb30550e to your computer and use it in GitHub Desktop.
Redux Reducer
const reducer = (state = '', action) => {
switch (action.type) {
case 'CHARACTER_TYPED':
const { character } = action;
return state + character;
case 'BACKSPACE':
return state.substr(0, state.length - 1);
default:
return state;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment