代码之家  ›  专栏  ›  技术社区  ›  Huy282002

将redux toolkit与JS一起使用时,不能跳过在CreateSicle()中键入状态

  •  0
  • Huy282002  · 技术社区  · 2 年前
        export const counterSlice = createSlice({
      name: "counter",
      initialState,
      // The `reducers` field lets us define reducers and generate associated actions
      reducers: {
        increment: (state) => {
          // Redux Toolkit allows us to write "mutating" logic in reducers. It
          // doesn't actually mutate the state because it uses the Immer library,
          // which detects changes to a "draft state" and produces a brand new
          // immutable state based off those changes
          state.value += 1;
        },
    

    Any的状态返回类型,而不是自动键入。我如何在不进行TypeScript的任何类型检查的情况下修复它

    0 回复  |  直到 2 年前