はい@ダニー・ワントは、AppState
を使用することができます。それはこのように使用することができます:_handleAppStateChange
:
getInitialState: function() {
return {
currentAppState: AppState.currentState,
};
},
componentDidMount: function() {
AppState.addEventListener('change', this._handleAppStateChange);
},
componentWillUnmount: function() {
AppState.removeEventListener('change', this._handleAppStateChange);
},
_handleAppStateChange: function(currentAppState) {
this.setState({ currentAppState, });
},
render: function() {
return (
<Text>Current state is: {this.state.currentAppState}</Text>
);
},
あなたはAppState
ハンドラ内で行いたいものを行います。詳細については、こちらをご覧ください。here
私はAppStateを使ってアプリケーションの状態を追跡しようと考えています。もっと良い方法があるかどうかまだ不思議です –