Created
May 11, 2020 15:38
-
-
Save pavinduLakshan/f4caae765d33d50fdee10643b8486039 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const initUserState = { | |
isAuth: false, | |
isAuthModalOpen: false | |
} | |
const initGalleryState = { | |
selectedPhotoURL: "" | |
} | |
const UserReducer = (state=initUserState,action) => { | |
switch(action.type){ | |
case "SET_AUTH": | |
return { | |
...state, | |
isAuth: action.status | |
} | |
case "IS_AUTH_MODAL_OPEN": | |
return { | |
...state, | |
isAuthModalOpen: action.isOpen | |
} | |
default: | |
return state; | |
} | |
} | |
const GalleryReducer = (state=initGalleryState,action) => { | |
switch(action.type){ | |
// here goes your case statements | |
default: | |
return state; | |
} | |
} | |
rootReducer = combineReducers({user: UserReducer, gallery: GalleryReducer}) | |
// the final state will look like below | |
{ | |
user: { | |
// user state variables go here | |
}, | |
gallery: { | |
// gallery state variables go here | |
} | |
} | |
export default RootReducer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment