Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // actions
- const LOGIN = 'LOGIN';
- function login(userData) {
- return { type: LOGIN, userData };
- }
- //reducer
- function users(state=[], action) {
- switch (action.type) {
- case LOGIN:
- return [...state, {
- text: 'Login'
- }];
- default:
- return state;
- }
- }
- // store
- let store = createStore(users, {
- username: 'Guest'
- });
- store.dispatch(login({username: 'th0th', password: '1'}));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement