Skip to content

Instantly share code, notes, and snippets.

@itsanna
Created June 2, 2016 20:39
Show Gist options
  • Save itsanna/fb0e1fe4390ddbbeb36868422928cdc7 to your computer and use it in GitHub Desktop.
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
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