Giter Club home page Giter Club logo

react-native-connection-notice's Introduction

React Native Connection Notice

A React Native component that gives a notice every time the user internet connection goes down

Installation

npm install react-native-connection-notice

Dependencies

You also need to install @react-native-community/netinfo.


If you have a Expo managed project, in your project directory, run:

npx expo install @react-native-community/netinfo

If you have a bare React Native project, in your project directory, run:

npm install --save @react-native-community/netinfo

If you encounter any problems with linking follow these additional installation instructions.

Preview

Lib Preview

Usage

Place the component in the App file below your others components

import ConnectionNotice from "react-native-connection-notice";

const App: React.FC = () => {
  return (
    <View style={{ flex: 1, alignItems: "center" }}>
      <StatusBar style="auto" />
      {/* your components... */}
      <ConnectionNotice />
    </View>
  );
};

export default App;

ConnectionNotice props

Props type description default
style StyleProp style of the notice container style default
styleText StyleProp style of the text inside the notice styleText default
height number height of the notice StatusBar.currentHeight or 40
offlineColor string background color when offline red
offlineText string text when offline No internet connection
onlineColor string background color when online green
onlineText string text when online Connected
slideDuration number duration of the slide in and out 200

style default

flexDirection: "row",
position: "absolute",
top: 0,
left: 0,
right: 0,
justifyContent: "center",
alignItems: "center",
width: Dimensions.get("screen").width

styleText default

color: "#FFF",

Hooks

useNetworkInfo

import { useNetworkInfo } from "react-native-connection-notice";

const App = () => {
  const isConnected = useNetworkInfo();

  return <Text>{isConnected ? "Connected" : "Not connected"}</Text>;
};

Listener that tells you if the device is connected to the internet

react-native-connection-notice's People

Contributors

itispx avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.