Gathering detailed insights and metrics for reason-react-native-netinfo
Gathering detailed insights and metrics for reason-react-native-netinfo
Gathering detailed insights and metrics for reason-react-native-netinfo
Gathering detailed insights and metrics for reason-react-native-netinfo
BuckleScript bindings to react-native-netinfo (in Reason syntax)
npm install reason-react-native-netinfo
Typescript
Module System
Node Version
NPM Version
15.6
Supply Chain
23.3
Quality
62.5
Maintenance
25
Vulnerability
90.8
License
OCaml (94.51%)
JavaScript (5.49%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
1 Stars
10 Commits
3 Branches
1 Contributors
Updated on Aug 28, 2019
Latest Version
3.2.4
Package Id
reason-react-native-netinfo@3.2.4
Unpacked Size
7.84 kB
Size
1.86 kB
File Count
6
NPM Version
6.9.0
Node Version
10.14.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
4
These are BuckleScript bindings to React Native NetInfo
, in Reason syntax. NetInfo
has been removed in RN 0.60, but as that release has breaking changes, this package is intended to work with RN 0.59.x releases as well. Accordingly, to avoid namespace clashes with the NetInfo
module in reason-react-native
(as would happen with open React Native
), the module has been named CommunityNetInfo
. In future releases, it is intended that the module be renamed NetInfo
.
Version of these bindings follow that of the React Native NetInfo
package.
Version | React Native version |
---|---|
4.00-beta | 0.60 or 0.59.x with jetifier |
3.2.x | 0.59.x |
You may update your existing code using NetInfo
module of reason-react-native
by replacing references to the ReactNative.NetInfo
module with CommunityNetInfo.Legacy
.
With yarn
:
1yarn add reason-react-native-netinfo
With npm
:
1npm install reason-react-native-netinfo
Once the package installation completes, @react-native-community/netinfo
should be linked to your project. You may use the CLI as below
1react-native link @react-native-community/netinfo
Finally, reason-react-native-netinfo
should be added to bs-dependencies
in BuckleScript
configuration of the project (bsconfig.json
). For example:
1{ 2 ... 3 "bs-dependencies": ["reason-react", "reason-react-native", "reason-react-native-netinfo"], 4 ... 5}
netInfoStateType
Kind of the current network connection. Valid values are:
Value | Platforms | Connection State |
---|---|---|
none | Android, iOS, Windows | Not active |
unknown | Android, iOS, Windows | Undetermined |
cellular | Android, iOS, Windows | Active |
wifi | Android, iOS, Windows | Active |
bluetooth | Android | Active |
ethernet | Android, Windows | Active |
wimax | Android | Active |
vpn | Android | Active |
other | Android, iOS, Windows | Active |
netInfoCellularGeneration
Cellular generation of the current network connection. Valid values are:
Value | Notes |
---|---|
net2g | Inlined as "2g". Returned for CDMA, EDGE, GPRS and IDEN connections |
net3g | Inlined as "3g". Returned for EHRPD, EVDO, HSPA, HSUPA, HSDPA and UTMS connections. |
net4g | Inlined as "4g". Returned for HSPAP and LTE connections |
details
1type details = {
2 .
3 "isConnectionExpensive": bool,
4 "cellularGeneration": Js.Nullable.t(netInfoCellularGeneration),
5};
netInfoState
1type netInfoState = {
2 .
3 "_type": netInfoStateType,
4 "isConnected": bool,
5 "details": Js.Null.t(details),
6};
details
key will have value Js.Null.empty
(null
) when _type
is null
or unknown
.
If the details
objects is not null
, the cellularGeneration
key within will
Js.Nullable.undefined
when _type
is wifi
, bluetooth
, ethernet
, wimax
, vpn
or other
.Js.Nullable.null
if the connection is not cellular or its generation cannot be determined.netInfoCellularGeneration
only when _type
is cellular
and its generation can be determined.fetch
To query the connection state, returns netInfoState
wrapped in a Promise
.
1fetch: unit => Js.Promise.t(netInfoState) = "";
Below example demonstrates determination of the cellular connection generation, using this method.
1React.useEffect0(() => {
2 Js.Promise.(
3 CommunityNetInfo.fetch()
4 |> then_(w =>
5 {
6 switch (w##details->Js.Null.toOption) {
7 | None => "Connection type is none or unknown"->Js.Console.warn
8 | Some(x) =>
9 let y = x##cellularGeneration;
10 switch (y->Js.Nullable.toOption) {
11 | None =>
12 if (y == Js.Nullable.undefined) {
13 "Connection type is wifi, bluetooth, ethernet, wimax, vpn or other"
14 ->Js.Console.warn;
15 } else {
16 "Connection generation unknown"->Js.Console.warn;
17 }
18 | Some(z) =>
19 if (z == CommunityNetInfo.net2G) {
20 "2G connection"->Js.Console.warn;
21 } else if (z == CommunityNetInfo.net3G) {
22 "3G connection"->Js.Console.warn;
23 } else {
24 "4G connection"->Js.Console.warn;
25 }
26 };
27 };
28 }
29 ->resolve
30 )
31 |> catch(err => "error"->Js.Console.warn->resolve)
32 |> ignore
33 );
34 None;
35});
addEventListener
To subscribe to the connection state; accepts a listener of type netInfoState => unit
and returns an unsubscribe method of type unit => unit
. The listener will be called once following subscription and each time connection state changes.
1addEventListener: (netInfoState => unit) => t;
where
1type t = unit => unit
Below example demonstrates subscribing to changes in connection state:
1React.useEffect0(() => {
2 let remove =
3 CommunityNetInfo.addEventListener(w =>
4 (
5 switch (w##details->Js.Null.toOption) {
6 | None => "Connection type is none or unknown"
7 | Some(x) =>
8 let y = x##cellularGeneration;
9 switch (y->Js.Nullable.toOption) {
10 | None =>
11 if (y == Js.Nullable.undefined) {
12 "Connection type is wifi, bluetooth, ethernet, wimax, vpn or other";
13 } else {
14 "Connection generation unknown";
15 }
16 | Some(z) =>
17 if (z == CommunityNetInfo.net2G) {
18 "2G connection";
19 } else if (z == CommunityNetInfo.net3G) {
20 "3G connection";
21 } else {
22 "4G connection";
23 }
24 };
25 }
26 )
27 ->Js.Console.warn
28 );
29 Js.Console.warn(remove);
30 Some(() => remove());
31});
useNetInfo
This method returns a React Hook with type netInfoState
1useNetInfo: unit => netInfoState
Below example demonstrates its use within a Text
component:
1<Text>
2 (
3 switch (CommunityNetInfo.useNetInfo()##details->Js.Null.toOption) {
4 | None => "Connection type is none or unknown"
5 | Some(x) =>
6 let y = x##cellularGeneration;
7 switch (y->Js.Nullable.toOption) {
8 | None =>
9 if (y == Js.Nullable.undefined) {
10 "Connection type is wifi, bluetooth, ethernet, wimax, vpn or other";
11 } else {
12 "Connection generation unknown";
13 }
14 | Some(z) =>
15 if (z == CommunityNetInfo.net2G) {
16 "2G connection";
17 } else if (z == CommunityNetInfo.net3G) {
18 "3G connection";
19 } else {
20 "4G connection";
21 }
22 };
23 }
24 )
25 ->React.string
26</Text>
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 0/10 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More