Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const defaultState = {
- login: false
- };
- const reducer = (state = defaultState, action) => {
- // change code below this line
- if (action.type == 'LOGIN') { //looks at the "type" of the action passed in.
- return {login:true} //returns object/new state if the action type is a login type
- } else {
- return state; //if the action object is not a login type, the current state is returned.
- } // change code above this line
- };
- const store = Redux.createStore(reducer);
- const loginAction = () => {
- return {
- type: 'LOGIN'
- }
- };
Add Comment
Please, Sign In to add comment