redux-toolkit
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.`
"@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;