Advertisement
Guest User

Untitled

a guest
Feb 25th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // actions
  2. const LOGIN = 'LOGIN';
  3.  
  4. function login(userData) {
  5.     return { type: LOGIN, userData };
  6. }
  7.  
  8. //reducer
  9. function users(state=[], action) {
  10.     switch (action.type) {
  11.         case LOGIN:
  12.             return [...state, {
  13.                 text: 'Login'
  14.             }];
  15.         default:
  16.             return state;
  17.     }
  18. }
  19.  
  20. // store
  21. let store = createStore(users, {
  22.     username: 'Guest'
  23. });
  24.  
  25. store.dispatch(login({username: 'th0th', password: '1'}));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement