Last active
December 11, 2017 07:18
-
-
Save Salman18/0176c77c302f012d264515edbd54a1c4 to your computer and use it in GitHub Desktop.
I am Dispatching Two Actions using dispatch Method.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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