Skip to content

Instantly share code, notes, and snippets.

@ilonacodes
Created December 9, 2018 16:43
Show Gist options
  • Save ilonacodes/165837b6c1ed62e82cb312aacbafc9df to your computer and use it in GitHub Desktop.
Save ilonacodes/165837b6c1ed62e82cb312aacbafc9df to your computer and use it in GitHub Desktop.
import {t} from './actions';
// starting with no data
const initState = {
user: null
};
export const userReducer = (state = initState, action) => {
switch (action.type) {
// tells the store that the user data is successfully retreived
// and no longer in the process of fetching another one on user request.
case t.LOAD_USER_DATA_SUCCESS:
return {
...state,
user: action.data
};
default:
return state;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment