【发布时间】:2017-04-10 14:04:57
【问题描述】:
我的减速机:
export default function summary(state = {
"summary":null
}, action = null) {
switch (action.type) {
case GET_SUMMARY_REQUEST_SUCCESS:
const newState = Object.assign({}, state);
newState.summary = action.data;
return newState;
break;
case GET_SUMMARY_REQUEST_ERROR:
return Object.assign({}, state, {
sumary:null
});
break;
default: return state;
}
};
根减速器:
import summary from './Summary.js'
const rootReducer = combineReducers({
summary
});
在我的组件中,我使用 connect 将状态映射到 props> 我的组件渲染功能是这样的:
render() {
const summary = this.props.summaryContent || [];
return (
<div className={cx(styles['loading'])} >
<Loader width="4" />
{"Loading\u2026"}
</div>
);
}
function mapStateToProps(state, ownParams) {
return {
summaryContent: state.summary
};
}
export default connect(mapStateToProps)(Summary);
在 componentWillMount 上,我正在调度一个动作以更新状态摘要。现在,我的 componentWillReceiveProps 向我展示了更新后的状态摘要,但组件没有呈现。
【问题讨论】: