Reactjs 当组件离开视图时,如何使用async Wait 如何使用异步等待?

Reactjs 当组件离开视图时,如何使用async Wait 如何使用异步等待?,reactjs,asynchronous,async-await,Reactjs,Asynchronous,Async Await,调用this.props.onChangeStep1()时,呈现视图的组件将替换为另一个组件 如果组件已交换,异步等待是否仍能工作 s3.upload(params, function(err, data) { this.props.onChangeStep1(); //<----- After s3.upload I want to call this first this.setState( //<----But I want this to r

调用this.props.onChangeStep1()时,呈现视图的组件将替换为另一个组件

如果组件已交换,异步等待是否仍能工作

s3.upload(params, function(err, data) {

this.props.onChangeStep1(); //<----- After s3.upload I want to call this first 

            this.setState(   //<----But I want this to run in the background 
                                  // even though the component is not in view
                  {
                myState: "data-from-s3Upload"
              });
          }.bind(this)
        );
s3.上传(参数、函数(错误、数据){

this.props.onChangeStep1();//如果回调设置为稍后执行,并且启动异步调用的组件已卸载,则回调将被执行。如果回调尝试对已卸载的组件执行操作(例如更改其状态)这将被视为内存泄漏,React将在控制台中以错误消息通知您。

this.props.onChangeStep1(e)//当您说“不在视图中”和“被另一个组件替换”时你的意思是它实际上已卸载?还是只是隐藏?它已卸载,因为…一旦ChangeStep使此组件与另一个组件交换,就会进行重新呈现,而在新的重新呈现上,此组件没有阅读这可能有何帮助..componentWillUnmount(){}componentWillUnmount()在卸载和销毁组件之前立即调用。在此方法中执行任何必要的清理,例如使计时器无效、取消网络请求或清理在componentDidMount()中创建的任何订阅。不应在componentWillUnmount()中调用setState()因为组件将永远不会重新呈现。一旦卸载组件实例,它将永远不会再次装载。感谢我确实收到了该错误,我解决该问题的方法是将所有逻辑转发回App.js componentthis.props.onChangeStep1(事件)
this.props.onChangeStep1(e) // <-- Forward data and Process logic on App.js / Parent Component