redux-toolkit icon indicating copy to clipboard operation
redux-toolkit copied to clipboard

`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.`

Open khteh opened this issue 1 year ago • 17 comments

"@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;

khteh avatar Dec 08 '23 07:12 khteh