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

@react-native-community/netinfo

Package Overview
Dependencies
Maintainers
1
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-native-community/netinfo - npm Package Compare versions

Comparing version 11.4.0 to 11.4.1

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## [11.4.1](https://github.com/react-native-netinfo/react-native-netinfo/compare/v11.4.0...v11.4.1) (2024-09-20)
### Bug Fixes
* ensure one reachability check in-flight at once / proper useEffect listener cleanup ([#732](https://github.com/react-native-netinfo/react-native-netinfo/issues/732)) ([eaed080](https://github.com/react-native-netinfo/react-native-netinfo/commit/eaed080))
# [11.4.0](https://github.com/react-native-netinfo/react-native-netinfo/compare/v11.3.3...v11.4.0) (2024-09-12)

@@ -2,0 +9,0 @@

34

lib/commonjs/index.js

@@ -67,3 +67,7 @@ "use strict";

return new _state2.default(_configuration);
};
}; // Track ongoing requests
let isRequestInProgress = false;
let requestQueue = [];
/**

@@ -77,3 +81,2 @@ * Configures the library with the given configuration. Note that calling this will stop all

function configure(configuration) {

@@ -121,5 +124,19 @@ _configuration = { ..._defaultConfiguration.default,

_state = createState();
} // If a request is already in progress, return a promise that will resolve when the current request finishes
if (isRequestInProgress) {
return new Promise(resolve => {
requestQueue.push(resolve);
});
}
return _state._fetchCurrentState();
isRequestInProgress = true;
return _state._fetchCurrentState().then(result => {
requestQueue.forEach(resolve => resolve(result));
requestQueue = [];
return result;
}).finally(() => {
isRequestInProgress = false;
});
}

@@ -171,3 +188,4 @@ /**

(0, _react.useEffect)(() => {
return addEventListener(setNetInfo);
const unsubscribe = addEventListener(setNetInfo);
return () => unsubscribe();
}, []);

@@ -209,3 +227,9 @@ return netInfo;

const refresh = (0, _react.useCallback)(() => {
networkInfoManager && networkInfoManager._fetchCurrentState();
if (networkInfoManager && !isRequestInProgress) {
isRequestInProgress = true;
networkInfoManager._fetchCurrentState().finally(() => {
isRequestInProgress = false;
});
}
}, [networkInfoManager]);

@@ -212,0 +236,0 @@ return {

@@ -22,3 +22,7 @@ /**

return new State(_configuration);
};
}; // Track ongoing requests
let isRequestInProgress = false;
let requestQueue = [];
/**

@@ -32,3 +36,2 @@ * Configures the library with the given configuration. Note that calling this will stop all

export function configure(configuration) {

@@ -74,5 +77,19 @@ _configuration = { ...DEFAULT_CONFIGURATION,

_state = createState();
} // If a request is already in progress, return a promise that will resolve when the current request finishes
if (isRequestInProgress) {
return new Promise(resolve => {
requestQueue.push(resolve);
});
}
return _state._fetchCurrentState();
isRequestInProgress = true;
return _state._fetchCurrentState().then(result => {
requestQueue.forEach(resolve => resolve(result));
requestQueue = [];
return result;
}).finally(() => {
isRequestInProgress = false;
});
}

@@ -122,3 +139,4 @@ /**

useEffect(() => {
return addEventListener(setNetInfo);
const unsubscribe = addEventListener(setNetInfo);
return () => unsubscribe();
}, []);

@@ -159,3 +177,9 @@ return netInfo;

const refresh = useCallback(() => {
networkInfoManager && networkInfoManager._fetchCurrentState();
if (networkInfoManager && !isRequestInProgress) {
isRequestInProgress = true;
networkInfoManager._fetchCurrentState().finally(() => {
isRequestInProgress = false;
});
}
}, [networkInfoManager]);

@@ -162,0 +186,0 @@ return {

@@ -19,4 +19,5 @@ /**

_refreshState: () => Promise<void>;
_triggerMultipleRefreshes: () => void;
render(): React.JSX.Element;
}
export {};

2

package.json
{
"name": "@react-native-community/netinfo",
"version": "11.4.0",
"version": "11.4.1",
"description": "React Native Network Info API for iOS & Android",

@@ -5,0 +5,0 @@ "react-native": "src/index.ts",

@@ -26,2 +26,6 @@ /**

// Track ongoing requests
let isRequestInProgress = false;
let requestQueue: ((state: Types.NetInfoState) => void)[] = [];
/**

@@ -78,3 +82,19 @@ * Configures the library with the given configuration. Note that calling this will stop all

}
return _state._fetchCurrentState();
// If a request is already in progress, return a promise that will resolve when the current request finishes
if (isRequestInProgress) {
return new Promise((resolve) => {
requestQueue.push(resolve);
});
}
isRequestInProgress = true;
return _state._fetchCurrentState().then((result) => {
requestQueue.forEach((resolve) => resolve(result));
requestQueue = [];
return result;
}).finally(() => {
isRequestInProgress = false;
});
}

@@ -128,3 +148,4 @@

useEffect((): (() => void) => {
return addEventListener(setNetInfo);
const unsubscribe = addEventListener(setNetInfo);
return () => unsubscribe();
}, []);

@@ -171,3 +192,8 @@

const refresh = useCallback(() => {
networkInfoManager && networkInfoManager._fetchCurrentState();
if (networkInfoManager && !isRequestInProgress) {
isRequestInProgress = true;
networkInfoManager._fetchCurrentState().finally(() => {
isRequestInProgress = false;
});
}
}, [networkInfoManager]);

@@ -174,0 +200,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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