redux请求api的时候,传参应该在哪个生命周期?
redux请求api的时候,传参应该在哪个生命周期?
//code...
getTopics(tab) {
this.props.dispatch((dispatch, getState) => {
axios.get(`/topics?tab=${tab}&page=1&limit=10`) .then(res => {
dispatch({
type: "Topics_Succ",
data: res.data
});
})
});
}
componentDidMount() {
this.getTopics('good');
this.getTopics('ask');
}
// render...
大家都是怎么用?
componentDidMount componentWillReceiveProps