[英]Redux Store not connected to React Component
我在这里有这个笨蛋:
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 Component(MyComponent)没有更新? 看来一切都很好。 分派了动作,然后在我的化简器中寻找动作“ LOAD_VALUES
”,然后返回新值,但是React Component不会得到更新并且保持不变。
谢谢!
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}
)。 更新了插件示例,使其看起来像现在一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.