Skip to content

Instantly share code, notes, and snippets.

@omitobi
Created January 26, 2018 11:04
Show Gist options
  • Select an option

  • Save omitobi/75b2500b527cf16254f19595af6e576e to your computer and use it in GitHub Desktop.

Select an option

Save omitobi/75b2500b527cf16254f19595af6e576e to your computer and use it in GitHub Desktop.
redux in bit
const reducer = ( state = [], action) => {
if (action.type === 'split_string') {
return action.payload.split('');
}
if (action.type === 'add_character') {
return [...state, action.payload];
}
return state;
};
const store = Redux.createStore(reducer);
store.getState();
const action = {
type: 'split_string',
payload: 'asdf'
};
store.dispatch(action);
store.getState();
const action2 = {
type: 'add_character',
payload: 'a'
};
store.dispatch(action2);
store.getState();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment