【问题标题】:Invoke Method in React Component after completion of API call in react redux saga在 React Redux 传奇中完成 API 调用后调用 React 组件中的方法
【发布时间】:2020-08-25 09:11:24
【问题描述】:
在我的 React ComponentDidMount 中,我正在调用一个异步操作,它将调用 redux saga 中的 API。
现在我的组件中有一个方法,应该在 API 调用完成后调用。
comnponentDidMount{
Action Call(); // API call in redux Saga
Method Call();
console.log('Done')
}
【问题讨论】:
标签:
reactjs
react-redux
redux-saga
【解决方案1】:
你可以用这个
componentDidUpdate(prevProps) {
if (prevProps.sp !== this.props.sp && !this.props.sp.fetching) {
//do whatever you want on finish of api call
}
}