Skip to content

Instantly share code, notes, and snippets.

@pavinduLakshan
Created May 11, 2020 15:38
Show Gist options
  • Save pavinduLakshan/f4caae765d33d50fdee10643b8486039 to your computer and use it in GitHub Desktop.
Save pavinduLakshan/f4caae765d33d50fdee10643b8486039 to your computer and use it in GitHub Desktop.
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