How do I get onresume event from React-Native?

React Native provides AppState to tell if the app is in the foreground or background, and notify us when the state changes.

    import React, {Component} from 'react'
    import {AppState, Text} from 'react-native'

    class AppStateExample extends Component {

      state = {
        appState: AppState.currentState
      }

      componentDidMount() {
        AppState.addEventListener('change', this._handleAppStateChange);
      }

      componentWillUnmount() {
        AppState.removeEventListener('change', this._handleAppStateChange);
      }

      _handleAppStateChange = (nextAppState) => {
        if (this.state.appState.match(/inactive|background/) && nextAppState === 'active') {
          console.log('App has come to the foreground!')
        }
        this.setState({appState: nextAppState});
      }

      render() {
        return (
          <Text>Current state is: {this.state.appState}</Text>
        );
      }

    }

source: https://facebook.github.io/react-native/docs/appstate.html

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)