nl pkr nl pkr -4 years ago 184
React JSX Question

Split Reducer in Big App

I try to organize My reducers (combineReducers) by different logic part in my app.


user: ...,
app: ...,
news: ...,

But have some problem with it. I build a big like social Media app (not exactly) and I have only 2 reducers like
, all logic in app work near user (messages, games, friends..) and I dont know how to split them.

It will be great if anyone have an experience with it and can advise something to me. Thanks.

Answer Source

If you're asking how to split appReducer and userReducer, then:

export default () => {

export default () => {

//your store
import appReducer from './appReducer';
import userReducer from './userReducer';
const store = createStore(combineReducers({ app: appReducer, user: userReducer}));

If you're asking how to split your userReducer because you feel like the reducer is getting too big, then you have to take them out of userReducer and make messagesReducer, friendsReducer, etc... Just because you feel like they're part of "user" object doesn't mean you have to have them all in the same userReducer. And that's what the action type is there for you and what flux/redux data flow helps you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download