0
export const makeStore = () => {
  const store = configureStore({
    reducer: {
      reducer,
      growthReportSlice,
      selectBarSlice,
    },
    ....
  return store;
};
const dummy = makeStore();

export const wrapper = createWrapper(makeStore, { debug: true });
export type AppDispatch = typeof dummy.dispatch;
// export type RootReducer = ReturnType<typeof reducer> &
//   ReturnType<typeof growthReportSlice> &
//   ReturnType<typeof selectBarSlice>;
export const useAppDispatch = () => useDispatch<AppDispatch>();

I just need the ReturnType of the root reducer but I have 3 reducers combined. How can I get the correct typing?

kmm3
  • 391
  • 3
  • 14

1 Answers1

2

You're almost there, you just need to combine your reducers.

import {combineReducers} from 'redux'
const rootReducer = combineReducers({
  reducer,
  growthReportsSlice,
  selectBarSlice
})

type RootState = ReturnType<typeof rootReducer>

...
const store = configureStore({
    reducer: rootReducer,
...
Orinayo Oyelade
  • 247
  • 2
  • 8