Closed badnorseman closed 8 years ago
@alleycat-at-git, it's worth commenting in the code that for a simple app, we really didn't need a bunch of this code, as this is geared for the case when we have many reducers in a bigger, real production app. Since we're making this setup work for real production apps, then this code is correct.
Anyway, this is symetrical to this code: https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/client/app/bundles/comments/store/commentsStore.js#L8
Another cool thing (maybe an issue for later) would be to see how we could re-use the non-component code in both web and native react projects. Maybe having one top level github project is the way to go that?
CC: @robwise
This is where we create the initial state for the entire store, which is a composition of each reducer's initial state mapped to that reducer's name in the store. This seems to be using the old createStore
syntax though.
since you're not merging anything from the initial props, I think you can just do:
import reducers, { initialStates } from '../reducers';
export default () => {
const rootReducer = combineReducers(reducers);
return createStore(rootReducer, initialStates, compose(applyMiddleware(thunkMiddleware, loggerMiddleware));
};
@robwise Agreed, since we won't have server rendering here, we can make it simpler
Someone interested to walk me through this and explain it?