Guest User

Untitled

a guest
Jul 16th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. const ADD_NOTE = 'ADD_NOTE';
  2.  
  3. const notesReducer = (state = 'Initial State', action) => {
  4. switch(action.type) {
  5. // change code below this line
  6. case ADD_NOTE: //note this is the constant, not used as a string. constant was assigned above.
  7. return action.text;
  8. break;
  9. // change code above this line
  10. default:
  11. return state;
  12. }
  13. };
  14.  
  15. const addNoteText = (note) => { //make sure to return an object within the "action" funtions
  16. // change code below this line
  17. return {
  18. type: ADD_NOTE,
  19. text: note
  20. }
  21. // change code above this line
  22. };
  23.  
  24. const store = Redux.createStore(notesReducer);
  25.  
  26. console.log(store.getState());
  27. store.dispatch(addNoteText('Hello!'));
  28. console.log(store.getState());
Add Comment
Please, Sign In to add comment