Nacho Cebey
Nacho Cebey

Reputation: 45

Can i have multiple Redux states (or a diferent structure) in my App?

Basiclaly, i have an app with multiple reducers combined with combineReducers(), as a normal react-redux structure, looks something like this:

So, is there any way to have an structure like:

Or in other hand, something like:

I know this probably breaks Redux's structural rules and isn't going to be the prettiest piece of code you've ever seen, but I just want to test different factors.

Thanks for all beforehand!

Upvotes: 0

Views: 36

Answers (1)

phry
phry

Reputation: 44076

Sure:

const store = configureStore({
  reducer: {
    part1: combineReducers({
      sub1: subReducer1,
      sub2: subReducer2,
    }),
    part2: combineReducers({
      sub3: subReducer3,
      sub4: subReducer4,
    }),
  },
});

There is no "breaking rules" anything going on there. You own the state structure.

Upvotes: 2

Related Questions