Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const ADD_NOTE = 'ADD_NOTE';
- const notesReducer = (state = 'Initial State', action) => {
- switch(action.type) {
- // change code below this line
- case ADD_NOTE: //note this is the constant, not used as a string. constant was assigned above.
- return action.text;
- break;
- // change code above this line
- default:
- return state;
- }
- };
- const addNoteText = (note) => { //make sure to return an object within the "action" funtions
- // change code below this line
- return {
- type: ADD_NOTE,
- text: note
- }
- // change code above this line
- };
- const store = Redux.createStore(notesReducer);
- console.log(store.getState());
- store.dispatch(addNoteText('Hello!'));
- console.log(store.getState());
Add Comment
Please, Sign In to add comment