Skip to content

Instantly share code, notes, and snippets.



Created Jan 16, 2019
What would you like to do?
the description for this gist
token: null,
userId: null,
error: null,
loading: false,
// ...
const reducer = (state = INITIAL_STATE, action) => {
switch(action.type) {
case actionTypes.AUTH_START:
return {...state, ...{ loading: true, error: null }};
case actionTypes.AUTH_SUCCESS:
return {...state, token: action.token, userId: action.userId, loading: false };
case actionTypes.AUTH_FAIL:
return {...state, loading: false, error: action.error };
case actionTypes.AUTH_LOGOUT:
return {...state, token: null, userId: null };
default: return state;
export default reducer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.