使用redux act时如何设置减速器名称

使用redux act时如何设置减速器名称,redux,Redux,我在和你玩。我已经使用createReducer创建了reducer,并将其连接到普通存储,就像普通的普通reducer一样 一开始我无法从state中获取值,但我意识到它实际上是作为reduce添加到state中的 我是否遗漏了一些东西,不应该被命名为函数名(即testState) 实际上应该是testState,看起来就像我试图复制时一样 export const setTestState = createAction("Set test state"); const testState

我在和你玩。我已经使用
createReducer
创建了reducer,并将其连接到普通存储,就像普通的普通reducer一样

一开始我无法从state中获取值,但我意识到它实际上是作为
reduce
添加到state中的

我是否遗漏了一些东西,不应该被命名为函数名(即
testState


实际上应该是
testState
,看起来就像我试图复制时一样

export const setTestState = createAction("Set test state");

const testState = createReducer(
  {
    [setTestState]: (state, payload) =>
      payload ? { ...payload, active: true } : null
  },
  null
);

// combined with others
createStore(combineReducers({...others, testState}))