Created
January 26, 2018 11:04
-
-
Save omitobi/75b2500b527cf16254f19595af6e576e to your computer and use it in GitHub Desktop.
redux in bit
This file contains hidden or 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(''); | |
| } | |
| 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