Reputation: 391
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?
Upvotes: 0
Views: 47
Reputation: 347
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,
...
Upvotes: 2