Skip to content

Type error: The inferred type of 'configureStore' cannot be named without a reference to '@reduxjs/toolkit/node_modules/redux'. This is likely not portable. A type annotation is necessary. #3962

Closed
@khteh

Description

@khteh

"@reduxjs/toolkit": "^2.0.1", eror:

import { configureStore, Middleware } from '@reduxjs/toolkit';
import { rootReducer } from './rootReducer'
const middlewares: Middleware[] = [];
// @link: https://redux.js.org/recipes/configuring-your-store#simplifying-setup-with-redux-toolkit
/*export const configureStore = (preloadedState = {}) => {
  const store = configureReduxStore({
    reducer: rootReducer,
    middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(middlewares),
    preloadedState,
  })

  if (process.env.NODE_ENV !== 'production' && module['hot']) {
    module['hot'].accept('./rootReducer', () => store.replaceReducer(rootReducer))
  }
  return store
}*/
const store = configureStore({
  reducer: rootReducer,
  middleware: (getDefaultMiddleware) =>
      getDefaultMiddleware().concat(middlewares),
});
export type AppDispatch = typeof store.dispatch;

export default store;

Metadata

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