Skip to content

Instantly share code, notes, and snippets.

@linux08
Created September 7, 2018 23:30
Show Gist options
  • Save linux08/64a41cf00a95464556ab97c503be6b18 to your computer and use it in GitHub Desktop.
Save linux08/64a41cf00a95464556ab97c503be6b18 to your computer and use it in GitHub Desktop.
import { combineReducers } from 'redux';
const rootReducer = (state = {
token: {},
loading: true,
error: null,
}, action) => {
switch (action.type) {
case 'GET_TOKEN':
return { ...state, token: action.token };
case 'SAVE_TOKEN':
return { ...state, token: action.token };
case 'REMOVE_TOKEN':
return { ...state, token: action.token };
case 'LOADING':
return { ...state, loading: action.isLoading };
case 'ERROR':
return { ...state, error: action.error };
default:
return state;
}
};
export default combineReducers({
token: rootReducer
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment