Morrys Repositories

Morrys Repositories

  • Docs
  • GitHub

›networking

wora

  • wora

caching

  • Cache Persist
  • Relay Store
  • Apollo Cache

networking

  • NetInfo
  • Detect Network

offline

  • Offline Architecture
  • Thinking Offline
  • Offline First
  • Relay Offline
  • Apollo Offline

Detect Network

@wora/detect-network

simple library that implements the react-native useNetInfo hook to use it also in the web

it is possible to use the useIsConnected hook with the only information if the network status is online or offline for both react-native and web

I opened an issue to request to implement useIsConnected inside the react-native-community/react-native-netinfo library

React

Install @wora/detect-network using yarn or npm:

yarn add @wora/detect-network
import { useIsConnected } from "@wora/detect-network";
import { useNetInfo } from "@wora/detect-network";

React Native (react-native-community/react-native-netinfo)

Install @wora/detect-network using yarn or npm:

yarn add @wora/detect-network react-native @react-native-community/netinfo

You then need to link the native parts of the library for the platforms you are using. The easiest way to link the library is using the CLI tool by running this command from the root of your project:

react-native link @react-native-community/netinfo

import { useIsConnected } from "@wora/detect-network";
import { useNetInfo } from "@wora/detect-network";

Example

const isConnected: boolean = useIsConnected();
const netInfo = useNetInfo();
Last updated on 2020-4-18 by morrys
← NetInfoOffline Architecture →
  • React
  • React Native (react-native-community/react-native-netinfo)
  • Example
Morrys Repositories
Docs
about wora
Community
User Showcase
More
GitHubStar
Follow @m0rrys
Facebook Open Source
Copyright © 2021 Lorenzo Di Giacomo