我试图用一个例子来研究redux流程。但是陷入了两者之间。这里是相同的plunkr链接。还原状态更新不正确
function combineReducers(currentState, action) {
var nextState = Object.assign({}, currentState);
/*On load placeholder details for all thumbnails*/
var placeholder = {
urlPath: "http://placehold.it/640x480",
header: "PLACEHOLDER",
description: "Description text for the above image"
};
if (currentState === undefined) {
nextState = placeholder;
return nextState;
}
//Problem here i guess
nextState = {
animals : animalReducer(nextState.animals, action),
architecture : architectureReducer(nextState.architecture, action)
}
return nextState;
}
应用程序加载初始状态为将所有媒体元素设置为占位符。 (这是工作) 在个别按钮点击,它应该获取每个类别的细节,只填充这些媒体元素。
问题:
当我点击执行按钮,或1层2的元件正在更新 在一起。理想的情况是我期待在4
我还没有实现3和4 点击元素1,元素2架构的细节,自然得到3 人们只动物细节,我相信,如果这个作品,那么它将更多地为每个状态添加额外的动作和缩减器。
我觉得问题出在rootReducer.js第19行或者index.js第34或37行,但不知道如何继续!任何指针都会有很大的帮助!今天我头上已经掉了很多头发!
PS:我知道的jQuery做的是一种污物的,但只是为了学习的目的!
高级感谢帮助者! 干杯。
感谢您的工作!确实有帮助 –