Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 30342

Netinfo.isConnected always returns true in Android

$
0
0

i am using react-native-netinfo in my app. In iOS it's working fine. But in android always returns true. It doesn't have internet connection (WiFi or Mobile data). It still returns true. Please give me any suggestions.

Versions:-

react-native:- 0.61.4,
@react-native-community/netinfo:- 4.6.1

Here is my code:-

  componentDidMount() {
    NetInfo.isConnected.addEventListener(
      'connectionChange',
      this.handleConnectivityChange,
    );
  }
  handleConnectivityChange = isConnected => {
    console.log('uyeuiyiuyiu', isConnected);
    this.setState({
      connectionStatus: isConnected,
    });
  };
  componentWillUnmount() {
    NetInfo.isConnected.removeEventListener(
      'connectionChange',
      this.handleConnectivityChange,
    );
  }

Viewing all articles
Browse latest Browse all 30342

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>