Guest User

Untitled

a guest
Jul 16th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. const defaultState = {
  2. login: false
  3. };
  4.  
  5. const reducer = (state = defaultState, action) => {
  6. // change code below this line
  7. if (action.type == 'LOGIN') { //looks at the "type" of the action passed in.
  8. return {login:true} //returns object/new state if the action type is a login type
  9. } else {
  10. return state; //if the action object is not a login type, the current state is returned.
  11. } // change code above this line
  12. };
  13.  
  14. const store = Redux.createStore(reducer);
  15.  
  16. const loginAction = () => {
  17. return {
  18. type: 'LOGIN'
  19. }
  20. };
Add Comment
Please, Sign In to add comment