Redux Store 未连接到 React Component

Redux Store not connected to React Component

我有这个 plunkr here:

ReactDOM.render(
        <ReactRedux.Provider store={store}>
          <div>
            <MyComponent/>
            <button onClick={loadInitialValues} className="btn btn-default">
              LOAD VALUES
            </button>
          </div>
        </ReactRedux.Provider>,
    document.getElementById('root')
);

为什么单击按钮“LOAD VALUES”时我的 React 组件 (MyComponent) 没有更新?似乎一切都很好。动作被调度,然后在我的减速器中我寻找动作“LOAD_VALUES”并且我 return 新值,但是 React 组件没有得到更新并保持不变。

谢谢!

 var suaReducer = function(state = Immutable.Map({
  modalProps: Immutable.Map({
    editMode: false,
    paymentType: Immutable.Map({})
  })
}), action) {
  switch(action.type) {
    case LOAD_VALUES:
      return state.merge({
        modalProps: Immutable.Map({
          editMode: true,
          paymentType: Immutable.Map({
            name: "TEST",
            notes: "TEST",
            amounts: [{
              amount: 100,
              year: 2017
            }]
          })
        })
      });
  }

  return state;
}

刚刚更改了您的 switch 语句而不是 action 使用 action.type 因为 action 是您正在调度的对象 ({type: LOAD_VALUES})。 更新了您的 plunker 示例,现在看起来它可以正常工作了。