0
哪里是在redux组件中加载数据的正确位置?在正在连接的redux组件中加载数据的正确位置
目前我有这种方式。
说我有这个容器组件:
import { loadResultsPage } from '../actions/winratio-actions';
function mapStateToProps(state) {
const {
isFetching,
results
} = state;
return {
isFetching,
results
};
};
export default connect(mapStateToProps, {
loadResultsPage
})(WinRatio);
然后我做在包装的组件的componentWillMount
生命周期事件的电话:
export default class WinRatio extends Component {
componentWillMount() {
this.props.loadResultsPage();
}
render() {
return (
<div>
<h1>Win Ratio</h1>
</div>
);
}
};
应该在哪里这个调用发生的呢?