【问题标题】: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 
          }
      }
    

    【讨论】:

      猜你喜欢
      • 2019-02-20
      • 2021-11-11
      • 1970-01-01
      • 2018-07-03
      • 1970-01-01
      • 2019-02-21
      • 2018-09-08
      • 2021-12-28
      • 2016-06-26
      相关资源
      最近更新 更多