
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
react-native-connection-info
Advanced tools
Higher order component for React Native to detect network connection state.
Higher order component for React Native to detect network connection state.
Use withConnection
to inject the connection
object which currently has the isConnected
property.
This is a boolean value that indicates internet connectivity status (see the NetInfo
documentation on isConnected
).
npm install --save react-native-connection-info
Make sure to also include permissions on Android. Add the following line to your AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
import React from 'react';
import {
Text,
View,
} from 'react-native';
import { withConnection, connectionShape } from 'react-native-connection-info';
const MyComponent = ({ connection }) => (
<View>
<Text
style={{ color: connection.isConnected ? 'lightskyblue' : 'lightcoral' }}
>
{connection.isConnected ? 'Connected' : 'Offline'}
</Text>
</View>
)
MyComponent.propTypes = {
connection: connectionShape,
};
export default withConnection(MyComponent);
Usage with redux is supported by default.
This section is only used if you need to reference the wrapped instance using getWrappedInstance()
when using react-redux
's connect()
. This component uses { withRef: true }
.
// instead of importing from 'react-native-connection-info'
// import { withConnection, connectionShape } from 'react-native-connection-info';
// just add /redux
import { withConnection, connectionShape } from 'react-native-connection-info/redux';
The rest is the same as in the first example.
FAQs
Higher order component for React Native to detect network connection state.
The npm package react-native-connection-info receives a total of 1 weekly downloads. As such, react-native-connection-info popularity was classified as not popular.
We found that react-native-connection-info demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.