I'm trying to implement a redux reset state action based off a suggestion from Dan Abramov here. I've setup my reducers and store like so:
Index.js:
import {applyMiddleware,createStore} from 'redux';
import combineReducers from './reducers/index';
import {wrapStore,alias} from 'react-chrome-redux';
import thunk from 'redux-thunk';
import aliases from './aliases/aliases';
const combineAppReducers = ( state, action ) => {
if ( action.type === 'LOG_OUT' ) {
state = undefined;
}
return combineReducers(state, action)
}
const middlewares = [alias(aliases), thunk];
const store = createStore(combineAppReducers,applyMiddleware(...middlewares));
wrapStore(store, {
portName: 'example'
});
Reducers.js:
import {combineReducers} from 'redux';
import userAuthReducer from './userAuthReducer';
import manageTeamsReducer from './manageTeamsReducer';
function lastAction(state = null, action) {
return action;
}
export default combineReducers({
userAuthReducer,manageTeamsReducer,lastAction
});
It looks as though I have set everything up correctly but the app is not resetting the state, can anyone spot where i've gone wrong?
Here is another article on it which I more closely followed:
https://medium.com/@agungsantoso/how-to-reset-the-state-of-a-redux-store-7f9d85b190bc