Skip to content

Instantly share code, notes, and snippets.

@jks8787
Last active August 2, 2017 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jks8787/657b1a8c7af73119a27b5f12e197d13b to your computer and use it in GitHub Desktop.
Save jks8787/657b1a8c7af73119a27b5f12e197d13b to your computer and use it in GitHub Desktop.
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