Created
September 7, 2018 23:30
-
-
Save linux08/64a41cf00a95464556ab97c503be6b18 to your computer and use it in GitHub Desktop.
This file contains 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
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