Skip to content

Instantly share code, notes, and snippets.

@nparsons08 nparsons08/reducer.js Secret forked from LukeSmetham/reducer.js
Created Sep 24, 2019

Embed
What would you like to do?
import { LOGIN } from './types';
const init = {
user: JSON.parse(localStorage.getItem('user')),
streamToken: localStorage.getItem('streamToken'),
loading: false,
error: false,
};
export default (state = init, action) => {
switch (action.type) {
case LOGIN.REQUEST:
return {
...state,
loading: true,
};
case LOGIN.SUCCESS:
return {
...state,
loading: false,
user: action.user,
streamToken: action.token,
};
default:
return state;
}
};
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.