2

I am experimenting with my code, and i was wondering if there was a cleaner way to combine the reducers with the combineReducers function.

for example, in my current reducer setup i have:

productList: productListReducer,
productDetails: productDetailsReducer,
productDelete: productDeleteReducer,
productCreate: productCreateReducer,
productUpdate: productUpdateReducer,
productReviewCreate: productReviewCreateReducer,
productTopRated: productTopRatedReducer,

these are all individual pieces of state, as i understand it, and to access them you simply use the useSelector hook, for example if i wanted the productList.

however what im thinking is perhaps a longshot but it would help keep the state more concise in my opinion. what im wanting to do is make it look like this:

product:
    {
      productList: productListReducer,
      productDetails: productDetailsReducer,
      productDelete: productDeleteReducer,
      productCreate: productCreateReducer,
      productUpdate: productUpdateReducer,
      productReviewCreate: productReviewCreateReducer,
      productTopRated: productTopRatedReducer,
    },

where the state is a combination of all the reducers themselves, so then if i wanted anything out of product like productList then i would pull that out of state. My Goal with this is to keep things organized and easier to find in state. However with this current setup the state never shows up in the react-redux-devtools

Austin Howard
  • 780
  • 4
  • 10
  • 24
  • Does this answer your question? [How to merge multiple reducers inside one state?](https://stackoverflow.com/questions/45769506/how-to-merge-multiple-reducers-inside-one-state) – MORÈ Jun 18 '22 at 15:43
  • yes! that works, using multiple combine reducers seems to be what i was missing. – Austin Howard Jun 18 '22 at 15:53

0 Answers0