Skip to content

Instantly share code, notes, and snippets.

@Salman18
Last active December 11, 2017 07:18
Show Gist options
  • Save Salman18/0176c77c302f012d264515edbd54a1c4 to your computer and use it in GitHub Desktop.
Save Salman18/0176c77c302f012d264515edbd54a1c4 to your computer and use it in GitHub Desktop.
I am Dispatching Two Actions using dispatch Method.
const reducer = ( state = [],action) => {
if (action.type === 'split_string') {
return action.payload.split('');
} else if (action.type === 'add_character') {
state.push(action.payload);
return state;
}
return state;
};
const store = Redux.createStore(reducer);
store.getState();
const action = {
type: 'split_string',
payload: 'AMCAT'
};
store.dispatch(action);
store.getState();
const action2 = {
type: 'add_character',
payload: 'S'
};
store.dispatch(action2);
store.getState();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment