When I raise the version of @reduxjs/toolkit from 1.6.2 to 1.7.1, I get the following error.
npx tsc
error TS2345: Argument of type 'DefaultRootState' is not assignable to parameter of type '{ readonly [$CombinedState]?: undefined; hoge: hogeEntityState; fuga: fugaEntityState; ... 20 more ...; suge: sugeEntityState; }'.
Type 'DefaultRootState' is missing the following properties from type '{ readonly [$CombinedState]?: undefined; hoge: hogeEntityState; fuga: fugaEntityState; ... 20 more ...; suge: sugeEntityState; }': hoge, fuga, and 19 more.
import { useSelector } from "react-redux";
import { hogeSelector } from "./hogeSlice.ts";
// error argument state
const hoge = useSelector((state) =>
hogeSelector(state, fuga.id)
hogeSlice.ts
import {
createSelector,
createEntityAdapter,
EntityState,
createSlice,
} from "@reduxjs/toolkit";
import { RootState } from "store";
import { HYDRATE } from "next-redux-wrapper";
const adapter = createEntityAdapter<Hoge>();
const initialState: EntityState<Hoge> = adapter.getInitialState({});
/** slice **/
export const hogeSlice = createSlice({
name: "hoge",
initialState,
reducers: {},
extraReducers: (builder) => {
builder
.addCase(HYDRATE, (state, action: any) => {
return { ...state, ...action.payload.hoge };
export const {
selectAll: hogesSelector
} = adapter.getSelectors((state: RootState) => state.hoge);
export const hogeSelector = createSelector(
hogesSelector,
(state, fugaId: number) => fugaId,
(entities, fugaId) => {
return xxxx;
store.ts
import { useDispatch } from "react-redux";
import logger from "redux-logger";
import { createWrapper } from "next-redux-wrapper";
import {
combineReducers,
configureStore,
Middleware,
// getDefaultMiddleware,
} from "@reduxjs/toolkit";
import { reducers } from "./reducers";
const rootReducer = combineReducers({
...reducers,
const createStore = () => {
return configureStore({
reducer: rootReducer,
middleware: (getDefaultMiddleware) =>
process.env.NODE_ENV === "production"
? getDefaultMiddleware()
: getDefaultMiddleware().concat(logger as Middleware),
export const store = createStore();
export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;
export const useAppDispatch = () => useDispatch<AppDispatch>();
export type AppStore = ReturnType<typeof createStore>;
export const wrapper = createWrapper<AppStore>(createStore);
reducers.ts
import { hogeSlice } from "./hogeSlice";
export type ReduxState = {
hoge: typeof hogeSlice.reducer;
export const reducers: ReduxState = {
hoge: hogeSlice.reducer
package.json
"@reduxjs/toolkit": "^1.7.1",
"react-redux": "^7.2.6", # or "react-redux": "v8.0.0-beta.2",
"typescript": "4.5"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
No one assigned
Labels
No labels
No labels
Type
No type
Projects
No projects
Milestone
No milestone
Relationships
None yet
Development
No branches or pull requests
Issue actions