类型错误:无法读取未定义的属性“类型”(redux 工具包)

Pet*_*ter 5 async-await react-hooks redux-toolkit

我正在尝试使用 redux 工具包获取一些数据,但它不起作用。我只是不断收到错误TypeError: Cannot read property 'type' of undefined。我正确设置了商店,因为我有其他减速器工作正常。但是当我尝试异步或获取数据时,我遇到了这个问题

错误:

在此输入图像描述

应用程序.js:

代码停在const actionResult = await dispath(getLiveContest())它之后不会控制台记录任何内容。

  const dispatch = useDispatch();

  useEffect(() => {
    const fetchLiveContest = async () => {
      try {
        console.log(1);
        const actionResult = await dispatch(getLiveContest());
        console.log(2);
        const liveContest = unwrapResult(actionResult);
        console.log(liveContest);
      } catch (error) {
        console.log("Failed to fetch live contest: ", error);
      }
    };

    fetchLiveContest();
  }, []);

Run Code Online (Sandbox Code Playgroud)

获取LiveContest():

这是该函数的代码。我尝试过return {name: 'lala'},但仍然出现类型错误

export const getLiveContest = createAsyncThunk(
  "contests/fetchLive",
  async (params, thunkAPI) => {
    console.log(thunkAPI, "thunkAPI");
    console.log(params);
    const liveContest = await axios ...

    return liveContest;
  }
);
Run Code Online (Sandbox Code Playgroud)

幻灯片代码:

export const liveContestSlide = createSlice({
  name: "live",
  initialState: {
    contest: [],
    loading: "idle",
  },
  reducers: {},
  extraReducers: {
    // Add reducers for additional action types here, and handle loading state as needed
    [getLiveContest.fulfilled]: (state, action) => {
      // Add contest to the state array
      state.contest.push(action.payload);
    },
  },
});
Run Code Online (Sandbox Code Playgroud)

我遵循了 redux 工具包文档。我还检查了 stackoverflow 上的其他问题,但仍然无法修复错误,请帮忙

Pet*_*ter 15

我只是更改import getLiveContest from "./contestSlice";为import { getLiveContest } from "./contestSlice";并且它有效,结果我只是导入了错误的函数