Why it is raised? Error: Minified Redux error #12;

Why it is raised? Error: Minified Redux error #12;

为什么我得到这个:

Error: Minified Redux error #12;

添加了Next.js基于此视频的 React 支持:

https://www.youtube.com/watch?v=QIqvxQnPOCM

//slices/User.ts

import { Action, createSlice, PayloadAction } from "@reduxjs/toolkit";
import { GetUserOut } from "../tikexModule/Types";

const initialState: GetUserOut = undefined;

const userSlice = createSlice({
  name: "user",
  initialState,
  reducers: {
    setUser(state, action: PayloadAction<GetUserOut | undefined>) {
      state = action.payload;
    },
  },
});

export const { setUser } = userSlice.actions;
export default userSlice.reducer;
//store.ts

import { configureStore } from "@reduxjs/toolkit";
import userReducer from "./slices/User";

export const store = configureStore({
  reducer: { user: userReducer },
});
//pages/_app.js

function MyApp({ Component, pageProps }) {
  return (
    <Provider store={store}>
      <Layout>
        <Component {...pageProps} />
      </Layout>
    </Provider>
  );
}

export default MyApp;

initialState 不允许是 undefined,因为 Redux 减速器永远不会 return undefined。请尝试 null