Advertisement
drooney57

Reduxit

Feb 19th, 2020
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. // change code below this line
  2. // I added:
  3. const LOGIN = "LOGIN";
  4. const LOGOUT = "LOGOUT";
  5. // change code above this line
  6. const defaultState = {
  7. authenticated: false
  8. };
  9. const authReducer = (state = defaultState, action) => {
  10. switch (action.type) {
  11. case 'LOGIN':
  12. return {
  13. authenticated: true
  14. }
  15. case 'LOGOUT':
  16. return {
  17. authenticated: false
  18. }
  19. default:
  20. return state;
  21. }
  22. };
  23. const store = Redux.createStore(authReducer);
  24. const loginUser = () => {
  25. return {
  26. type: 'LOGIN'
  27. }
  28. };
  29. const logoutUser = () => {
  30. return {
  31. type: 'LOGOUT'
  32. }
  33. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement