I am trying to setup reducers of both connected-react-router and RTK Query.
(The old code base has connected-react-router already)
Then I received this error.
Type 'Reducer<RouterState<unknown>, AnyAction>' is not assignable to type 'Reducer<unknown, AnyAction>'.
Types of parameters 'state' and 'state' are incompatible.
Type 'unknown' is not assignable to type 'RouterState<unknown>'.
My "mockApi" is quite simple. "orderApi" is somewhat the same.
export const mockApi = createApi({
reducerPath: "mockupPath",
baseQuery: fetchBaseQuery({ baseUrl: "http://jsonplaceholder.typicode.com" }),
endpoints: (builder) => ({
getPost: builder.query<MockResonse, number>({
query: (id) => `/posts/${id}`,
}),
}),
})
interface MockResonse { userId: number, id: number, title: string, body: string, }
While using combineReducers produces no type error,
reducer: combineReducers({
router: connectRouter(history),
[mockApi.reducerPath]: mockApi.reducer,
}),
but I lose the type of the store.
Knowing the type of the store is a huge advantage in development, so I'm trying to figure out how to solve the error.
May I know if I'm wrong somewhere?