I'm trying to add the RTK-Query middleware to a nested store structure, I'm getting a very long and non-descriptive typescript error when I add the api middleware...
Here's my code:
export const rootReducer = combineReducers({
foo: fooReducer,
nested: combineReducers({
bar: barReducer,
[myFooApi.reducerPath]: myFooApi.reducer,
})
});
const store = configureStore({
reducer: rootReducer,
middleware: (getDefaultMiddleware) => // Getting TS2322 error: type is not assignable to type...
getDefaultMiddleware().concat(tokenListsApi.middleware)
});
The error disappears when I move [fooApi.reducerPath]
to the root of the reducer like so:
export const rootReducer = combineReducers({
foo: fooReducer,
bar: barReducer,
[fooApi.reducerPath]: fooApi.reducer,
});
I was looking for examples of a nested usage of the RTK-Query Api reducer but couldn't find any... what am I missing?