在iOS上的React Native中,有没有办法确定应用程序何时恢复?比如onResume事件?

Mic*_*sel 6 reactjs react-native

我正在尝试确定应用程序何时恢复.例如,当您打开应用程序时,请按设备上的主页按钮,然后返回应用程序.

Phy*_*hyo 14

希望你正在寻找这个. 文档在这里

getInitialState: function() {
  return {
    currentAppState: AppStateIOS.currentState,
  };
},
componentDidMount: function() {
  AppStateIOS.addEventListener('change', this._handleAppStateChange);
},
componentWillUnmount: function() {
    AppStateIOS.removeEventListener('change', this._handleAppStateChange);
},
_handleAppStateChange: function(currentAppState) {
  this.setState({ currentAppState, });
},
render: function() {
  return (
     <Text>Current state is: {this.state.currentAppState}</Text>
 );
},
Run Code Online (Sandbox Code Playgroud)