Skip to content

Instantly share code, notes, and snippets.

@jks8787 jks8787/rootReducer.js Secret
Last active Aug 2, 2017

Embed
What would you like to do?
reducers for react+ redux -- Medium Article gist
import {combineReducers} from 'redux';
import stuff from './stuffReducer';
const rootReducer = combineReducers({
stuff
});
export default rootReducer;
import initialState from './initialState';
import {FETCH_STUFF, RECEIVE_STUFF} from '../actions/actionTypes';
export default function stuff(state = initialState.stuff, action) {
let newState;
switch (action.type) {
case FETCH_STUFF:
console.log('FETCH_STUFF Action')
return action;
case RECEIVE_STUFF:
newState = action.stuff;
console.log('RECEIVE_STUFF Action')
return newState;
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.