Created
June 2, 2016 20:39
-
-
Save itsanna/fb0e1fe4390ddbbeb36868422928cdc7 to your computer and use it in GitHub Desktop.
Reducer that takes in previous `github` state and returns the new `github` state
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
const initialState = { | |
user: {} | |
} | |
export default function github(state = initialState, action) { | |
switch (action.type) { | |
case 'REQUEST_USER': | |
return { ...state, isFetchingUser: true } | |
case 'RECEIVE_USER': { | |
return { | |
...state, | |
isFetchingUser: false, | |
user: action.user | |
} | |
} | |
default: | |
return state | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment