Skip to content

TypeError: getDefaultMiddleware is not a function #1499

@rick-chou

Description

@rick-chou

@reduxjs/toolkit version 1.6.1

I followed the official website and wrote the following code and then i got an error

TypeError: getDefaultMiddleware is not a function

import { configureStore } from '@reduxjs/toolkit';
import counterReducer from './modules/counterSlice';
import logger from 'redux-logger';

export const store = configureStore({
  reducer: {
    counter: counterReducer,
    middleware: (getDefaultMiddleware: any) => getDefaultMiddleware().concat(logger),
  },
});

// Infer the `RootState` and `AppDispatch` types from the store itself
export type RootState = ReturnType<typeof store.getState>;
// Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState}
export type AppDispatch = typeof store.dispatch;

截屏2021-09-11 上午11 10 11

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