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)
| 归档时间: |
|
| 查看次数: |
3838 次 |
| 最近记录: |