Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-offline

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-offline - npm Package Compare versions

Comparing version 3.1.1 to 3.2.0

2

package.json
{
"name": "react-native-offline",
"version": "3.1.1",
"version": "3.2.0",
"description": "Handy toolbelt to deal with offline mode in React Native applications. Cross-platform, provides a smooth redux integration.",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

@@ -67,3 +67,4 @@ # react-native-offline

timeout?: number = 3000,
pingServerUrl?: string = 'https://google.com'
pingServerUrl?: string = 'https://google.com',
withExtraHeadRequest?: boolean = true,
}

@@ -79,2 +80,4 @@ ```

`withExtraHeadRequest`: flag that denotes whether the extra ping check will be performed or not. Defaults to `true`.
##### Usage

@@ -94,3 +97,3 @@ ```js

#### `ConnectivityRenderer`
React component that accepts a function as children. It allows you to decouple your parent component and your child component, managing connectivity state on behalf of the components it is composed with, without making demands on how that state is leveraged by its children. Useful for conditionally render different children based on connectivity status. `timeout` and `pingServerUrl` can be provided through props in this case.
React component that accepts a function as children. It allows you to decouple your parent component and your child component, managing connectivity state on behalf of the components it is composed with, without making demands on how that state is leveraged by its children. Useful for conditionally render different children based on connectivity status. `timeout`, `pingServerUrl` and `withExtraHeadRequest` can be provided through props in this case.

@@ -101,4 +104,5 @@ ##### Props

children: (isConnected: boolean) => React$Element<any>
timeout?: number,
pingServerUrl?: string
timeout?: number = 3000,
pingServerUrl?: string = 'https://google.com',
withExtraHeadRequest?: boolean = true,
}

@@ -105,0 +109,0 @@ ```

@@ -12,2 +12,3 @@ /* @flow */

pingServerUrl?: string,
withExtraHeadRequest?: boolean,
};

@@ -28,2 +29,3 @@

pingServerUrl: PropTypes.string,
withExtraHeadRequest: PropTypes.bool,
};

@@ -34,2 +36,3 @@

pingServerUrl: 'https://google.com',
withExtraHeadRequest: true,
};

@@ -54,8 +57,17 @@

componentDidMount() {
NetInfo.isConnected.addEventListener('change', this.checkInternet);
NetInfo.isConnected.addEventListener(
'change',
this.props.withExtraHeadRequest
? this.checkInternet
: this.handleConnectivityChange,
);
// On Android the listener does not fire on startup
if (Platform.OS === 'android') {
NetInfo.isConnected
.fetch()
.then((isConnected: boolean) => this.checkInternet(isConnected));
NetInfo.isConnected.fetch().then((isConnected: boolean) => {
if (this.props.withExtraHeadRequest) {
this.checkInternet(isConnected);
} else {
this.handleConnectivityChange(isConnected);
}
});
}

@@ -65,3 +77,8 @@ }

componentWillUnmount() {
NetInfo.isConnected.removeEventListener('change', this.checkInternet);
NetInfo.isConnected.removeEventListener(
'change',
this.props.withExtraHeadRequest
? this.checkInternet
: this.handleConnectivityChange,
);
}

@@ -68,0 +85,0 @@

@@ -15,2 +15,3 @@ /* @flow */

pingServerUrl?: string,
withExtraHeadRequest?: boolean,
};

@@ -27,2 +28,3 @@

pingServerUrl = 'https://google.com',
withExtraHeadRequest = true,
}: Arguments = {},

@@ -54,8 +56,17 @@ ) => (WrappedComponent: ReactClass<*>) => {

componentDidMount() {
NetInfo.isConnected.addEventListener('change', this.checkInternet);
NetInfo.isConnected.addEventListener(
'change',
withExtraHeadRequest
? this.checkInternet
: this.handleConnectivityChange,
);
// On Android the listener does not fire on startup
if (Platform.OS === 'android') {
NetInfo.isConnected
.fetch()
.then((isConnected: boolean) => this.checkInternet(isConnected));
NetInfo.isConnected.fetch().then((isConnected: boolean) => {
if (withExtraHeadRequest) {
this.checkInternet(isConnected);
} else {
this.handleConnectivityChange(isConnected);
}
});
}

@@ -65,3 +76,8 @@ }

componentWillUnmount() {
NetInfo.isConnected.removeEventListener('change', this.checkInternet);
NetInfo.isConnected.removeEventListener(
'change',
withExtraHeadRequest
? this.checkInternet
: this.handleConnectivityChange,
);
}

@@ -68,0 +84,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc