【发布时间】:2016-11-28 19:09:35
【问题描述】:
假设我有一个 rootreducer,如下所示。
const rootR = combineReducers({
topics,
...
});
主题 reducer
function topics(state = { topics=[], error: null}, action){
switch (action.type){
case types.FETCH_TOPICS_SUCCESSFULLY:
const { topics } = action;
return {
...state,
topics,
};
default:
return state;
}
};
当我触发相关操作时,我会使用可重复属性 state.topics.topics 而不是 state.topics 获得我的状态
有什么办法可以避免这种重复(topics.topics)?
提前致谢
【问题讨论】:
-
const { topics } = action;这里的主题对象是什么样的? -
@finalfreq 这是对象数组,例如 >
{userId, theme, body}
标签: javascript reactjs ecmascript-6 redux