在react redux saga中完成API调用后,在React Component中调用方法

问题描述 投票:0回答:1

在我的React ComponentDidMount中,我正在调用一个异步操作,该操作将在redux传奇中调用API。现在,我的组件中有一个方法,应该在API调用完成后调用。

comnponentDidMount{
Action Call(); // API call  in redux Saga
Method Call();
console.log('Done')
}
reactjs react-redux redux-saga
1个回答
0
投票

您可以使用此

    componentDidUpdate(prevProps) {

      if (prevProps.sp !== this.props.sp && !this.props.sp.fetching) {
         //do whatever you want on finish of api call 
      }
  }
© www.soinside.com 2019 - 2024. All rights reserved.