Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Getting the root reducer from configureStore redux toolkit

$
0
0
import { configureStore } from "@reduxjs/toolkit";import testSlice from "./testSlice";import {combineReducers} from "redux";const rootReducer = combineReducers({test: testSlice})export const store = configureStore({  reducer: rootReducer,});export type RootState = ReturnType<typeof rootReducer>

This is my current workaround in order to get the type of my root reducer. I'm reading the docs and I can't seem to find how to get my root reducer from the store if I was using slices to create the reducer in my configure store. It's just disappointing that I have to use combineReducers again while using redux-toolkit just to get my rootReducer type.

I'm looking for a code like this:

import { configureStore } from "@reduxjs/toolkit";import testSlice from "./testSlice";import userSlice from "./userSlice";export const store = configureStore({  reducer: {test: testSlice, user: userSlice},});export type RootState = ReturnType<typeof store.getReducer()>

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>