reactnative-netinfo-mixin

Update state of component to pass NetInfo value isConnected

Usage no npm install needed!

<script type="module">
  import reactnativeNetinfoMixin from 'https://cdn.skypack.dev/reactnative-netinfo-mixin';
</script>

README

This Mixin define a state NetInfo for your component

Install

$ npm i --save reactnative-netinfo-mixin

Usage

import React from 'react';
import { View, Text } from 'react-native';
import NetInfoMixin from 'reactnative-netinfo-mixin';

const MyComponent = React.createClass({
    mixins: [ NetInfoMixin ],

    render() {
        return (
            <View>
                <Text>{ this.state.NetInfo.isConnected ? 'online' : 'offline' }</Text>
            </View>
        );
    }

});