Skip to content

Instantly share code, notes, and snippets.

@nazrdogan
Created June 26, 2018 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nazrdogan/134b85b097c316d303ed0b032a96e4e6 to your computer and use it in GitHub Desktop.
Save nazrdogan/134b85b097c316d303ed0b032a96e4e6 to your computer and use it in GitHub Desktop.
import { combineReducers } from "redux";
import { nav } from "./routeReducer";
import * as ActionTypes from '.././constant/actionTypes';
import { reducer as formReducer } from 'redux-form'
import { locationReducer as location } from 'redux-saga-location';
import {reducer as network} from 'react-native-offline';
// Pages Reducers
import loginReducer from '.././pages/Login/loginReducer';
import historyReducer from '.././pages/History/historyReducer';
import registerReducer from '.././pages/Register/registerReducer';
import forgotPasswordReducer from '.././pages/ResetPassword/resetPasswordReducer';
import carAdviceReducer from '.././pages/CarAdvice/carAdviceReducer';
import carListReducer from '.././pages/CarList/carListReducer';
import moreInfoReducer from '.././pages/MoreInfo/moreInfoReducer';
import profileReducer from '.././pages/Profile/profileReducer';
import priceReducer from '.././pages/Price/priceReducer';
import reservationReducer from '.././pages/Reservation/reservationReducer';
import opendoorsReducer from '.././pages/OpenDoors/opendoorsReducer';
const AppReducer = combineReducers({
nav,
loginReducer,
historyReducer,
registerReducer,
forgotPasswordReducer,
carAdviceReducer,
carListReducer,
moreInfoReducer,
profileReducer,
priceReducer,
opendoorsReducer,
reservationReducer,
location,
network,
form: formReducer
});
/**
* Thanks to Dan Abramov
* https://stackoverflow.com/questions/35622588/how-to-reset-the-state-of-a-redux-store/35641992#35641992
*
* @param {any} state
* @param {any} action
* @returns
*/
const rootReducer = (state, action) => {
if (action.type === ActionTypes.LOGOUT_USER) {
const { nav } = state
state = { nav }
}
return AppReducer(state, action)
}
export default rootReducer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment