Skip to content

Instantly share code, notes, and snippets.

@aviraldg
Created April 6, 2016 02:37
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 aviraldg/5c9341039c9b3d46f7d0cdd3a0ba0f80 to your computer and use it in GitHub Desktop.
Save aviraldg/5c9341039c9b3d46f7d0cdd3a0ba0f80 to your computer and use it in GitHub Desktop.
/* Combine all available reducers to a single root reducer.
*
* CAUTION: When using the generators, this file is modified in some places.
* This is done via AST traversal - Some of your formatting may be lost
* in the process - no functionality should be broken though.
* This modifications only run once when the generator is invoked - if
* you edit them, they are not updated again.
*/
import { combineReducers } from 'redux';
/* Populated by react-webpack-redux:reducer */
const reducers = { navigation: require('./navigation') };
export default combineReducers(reducers);
const initialState = {
};
export default function(state = initialState, action) {
/* Keep the reducer clean - do not mutate the original state. */
// let nextState = Object.assign({}, state);
switch(action.type) {
default: {
/* Return original state if no actions were consumed. */
return state;
}
}
}
'use strict';
const redux = require('redux');
import reducers from '../reducers';
import thunkMiddleware from 'redux-thunk';
import loggerMiddleware from 'redux-logger';
export default function configureStore(initialState) {
const store = redux.createStore(reducers,
initialState,
redux.applyMiddleware(thunkMiddleware, loggerMiddleware)
);
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('../reducers', () => {
const nextReducer = require('../reducers');
store.replaceReducer(nextReducer)
})
}
return store
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment