Skip to content

Commit 85a108c

Browse files
authored
@reason-react-native/netinfo@4.1.0 (#590)
1 parent 2dcb741 commit 85a108c

File tree

6 files changed

+90
-61
lines changed

6 files changed

+90
-61
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ocaml / Reason / BuckleScript artifacts
2+
.bsb.lock
3+
**/lib/bs
4+
**/lib/ocaml
5+
**/.merlin
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Changelog
2+
3+
## 4.1.0
4+
5+
### Breaking Changes
6+
7+
- Moved from
8+
[sgny/reason-react-native-netinfo](https://github.com/sgny/reason-react-native-netinfo#readme).
9+
`npm` package was previously named `reason-react-native-netinfo`. Please
10+
update your dependencies accordingly. You may update your existing code using
11+
the `NetInfo` module of `reason-react-native` by replacing references to the
12+
`ReactNative.NetInfo` module with `ReactNativeNetInfo.Legacy`. However, do
13+
note that the new API is more straightforward.
14+
15+
- The module is renamed to `ReactNativeNetInfo` (previously`CommunityNetInfo`).
16+
17+
- Releases require use of [jetifier](https://github.com/mikehardy/jetifier) for
18+
versions 0.59.x of React Native. You may continue to use
19+
[`reason-react-native-netinfo`](https://www.npmjs.com/package/reason-react-native-netinfo)
20+
version 3.2.x if you do not wish to use `jetifier`.
21+
22+
## 3.x
23+
24+
See
25+
[sgny/reason-react-native-netinfo](https://github.com/sgny/reason-react-native-netinfo/tree/3.2.4])

@reason-react-native/netinfo/README.md

Lines changed: 36 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,64 @@
1-
# BuckleScript bindings to React Native NetInfo
1+
# BuckleScript bindings to `@react-native-community/netinfo`
22

33
[![Version](https://img.shields.io/npm/v/@reason-react-native/netinfo.svg)](https://www.npmjs.com/@reason-react-native/netinfo)
44

5-
These are BuckleScript bindings to
6-
[`React Native NetInfo`](https://github.com/react-native-community/react-native-netinfo),
7-
in Reason syntax. `NetInfo` has been removed from the React Native core with
8-
version 0.60, but as that release has breaking changes, this package is intended
9-
to work with React Native 0.59.x releases as well. Accordingly, to avoid
10-
namespace clashes with the `NetInfo` module in `reason-react-native` (as would
11-
happen with `open React Native`) and for consistency with other projects, the
12-
module has been named `ReactNativeNetInfo`.
5+
Reason / BuckleScript bindings for
6+
[`@react-native-community/netinfo`](https://github.com/react-native-community/react-native-netinfo)
7+
(exposed as `ReactNativeNetInfo`).
138

14-
Version of these bindings follow that of the `React Native NetInfo` package.
15-
React Native versions 0.59.x and 0.60.x are supported, however
16-
[jetifier](https://github.com/mikehardy/jetifier) is required to support
17-
versions 0.59.x.
9+
## Support
1810

19-
| Version | React Native version | `npm` package for Reason bindings |
20-
| ------- | --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
21-
| 4.1.x | 0.60 or 0.59.x with [jetifier](https://github.com/mikehardy/jetifier) | [`@reason-react-native/netinfo`](https://www.npmjs.com/@reason-react-native/netinfo) |
22-
| 3.2.x | 0.59.x | [`reason-react-native-netinfo`](https://www.npmjs.com/package/reason-react-native-netinfo) |
11+
`@reason-react-native/netinfo` X.y._ means it's compatible with
12+
`@react-native-community/netinfo` X.y._
2313

24-
You may update your existing code using the `NetInfo` module of
25-
`reason-react-native` by replacing references to the `ReactNative.NetInfo`
26-
module with `ReactNativeNetInfo.Legacy`. However, do note that the new API is
27-
more straightforward.
14+
| version | react-native version |
15+
| ------- | -------------------- |
16+
| 4.1.0+ | 0.60.0+ |
2817

29-
## Breaking Changes
30-
31-
- Moved from
32-
[sgny/reason-react-native-netinfo](https://github.com/sgny/reason-react-native-netinfo#readme).
33-
`npm` package was previously named `reason-react-native-netinfo`. Please
34-
update your dependencies accordingly.
35-
36-
- The module is renamed to `ReactNativeNetInfo` (previously`CommunityNetInfo`).
37-
38-
- Releases require use of [jetifier](https://github.com/mikehardy/jetifier) for
39-
versions 0.59.x of React Native. You may continue to use
40-
[`reason-react-native-netinfo`](https://www.npmjs.com/package/reason-react-native-netinfo)
41-
version 3.2.x if you do not wish to use `jetifier`.
18+
For 0.59-, you should use
19+
[`jetify -r`](https://github.com/mikehardy/jetifier/blob/master/README.md#to-reverse-jetify--convert-node_modules-dependencies-to-support-libraries).
4220

4321
## Installation
4422

4523
With `yarn`:
4624

47-
```shell
25+
```console
4826
yarn add @reason-react-native/netinfo
4927
```
5028

5129
With `npm`:
5230

53-
```shell
31+
```console
5432
npm install @reason-react-native/netinfo
5533
```
5634

57-
Once package installation completes, `@react-native-community/netinfo` should be
58-
linked to your project. You may use the CLI as below:
35+
If you use React Native 0.60, `@react-native-community/netinfo` should be linked
36+
to your project:
5937

60-
```shell
38+
```console
6139
react-native link @react-native-community/netinfo
6240
```
6341

6442
Finally, `@reason-react-native/netinfo` should be added to `bs-dependencies` in
6543
`BuckleScript` configuration of the project (`bsconfig.json`). For example:
6644

67-
```json
45+
```diff
6846
{
69-
...
70-
"bs-dependencies": ["reason-react", "reason-react-native", "@reason-react-native/netinfo"],
71-
...
47+
//...
48+
"bs-dependencies": [
49+
"reason-react",
50+
"reason-react-native",
51+
+ "@reason-react-native/netinfo"
52+
],
53+
//...
7254
}
7355
```
7456

75-
## Types
57+
## Usage
58+
59+
### Types
7660

77-
### `netInfoStateType`
61+
#### `netInfoStateType`
7862

7963
Kind of the current network connection. Valid values are:
8064

@@ -90,7 +74,7 @@ Kind of the current network connection. Valid values are:
9074
| `vpn` | Android | Active |
9175
| `other` | Android, iOS, Windows | Active |
9276

93-
### `netInfoCellularGeneration`
77+
#### `netInfoCellularGeneration`
9478

9579
Cellular generation of the current network connection. Valid values are:
9680

@@ -100,7 +84,7 @@ Cellular generation of the current network connection. Valid values are:
10084
| `net3g` | Inlined as "3g". Returned for EHRPD, EVDO, HSPA, HSUPA, HSDPA and UTMS connections. |
10185
| `net4g` | Inlined as "4g". Returned for HSPAP and LTE connections |
10286

103-
### `details`
87+
#### `details`
10488

10589
```reason
10690
type details = {
@@ -110,7 +94,7 @@ type details = {
11094
};
11195
```
11296

113-
### `netInfoState`
97+
#### `netInfoState`
11498

11599
```reason
116100
type netInfoState = {
@@ -133,9 +117,9 @@ If the `details` objects is not `null`, the `cellularGeneration` key within will
133117
- be of type `netInfoCellularGeneration` only when `_type` is `cellular` and its
134118
generation can be determined.
135119

136-
## Methods
120+
### Methods
137121

138-
### `fetch`
122+
#### `fetch`
139123

140124
To query the connection state, returns `netInfoState` wrapped in a `Promise`.
141125

@@ -184,7 +168,7 @@ React.useEffect0(() => {
184168
});
185169
```
186170

187-
### `addEventListener`
171+
#### `addEventListener`
188172

189173
To subscribe to the connection state; accepts a listener of type
190174
`netInfoState => unit` and returns an unsubscribe method of type `unit => unit`.
@@ -237,7 +221,7 @@ React.useEffect0(() => {
237221
});
238222
```
239223

240-
### `useNetInfo`
224+
#### `useNetInfo`
241225

242226
This method returns a React Hook with type `netInfoState`
243227

@reason-react-native/netinfo/package.json

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,30 @@
99
"reasonml",
1010
"bucklescript",
1111
"react-native",
12-
"react-native-netinfo"
12+
"react-native-netinfo",
13+
"netinfo"
14+
],
15+
"files": [
16+
"*",
17+
"!.DS_Store",
18+
"!**/*.bs.js",
19+
"!.merlin",
20+
"!lib/bs",
21+
"!lib/ocaml"
1322
],
1423
"scripts": {
15-
"clean": "bsb -clean-world",
1624
"start": "bsb -make-world -w",
1725
"build": "bsb -make-world",
18-
"clean-build": "bsb -clean-world -make-world"
26+
"clean": "bsb -clean-world",
27+
"test": "bsb -clean-world -make-world"
1928
},
20-
"peerDependencies": {
21-
"bs-platform": "~5.0.4",
22-
"react-native": "~0.59.9",
29+
"devDependencies": {
30+
"bs-platform": "^5.0.4",
2331
"reason-react": "^0.7.0",
24-
"reason-react-native": "^0.60.0"
32+
"reason-react-native": "^0.60.0",
33+
"@react-native-community/netinfo": "^4.1.0"
2534
},
26-
"dependencies": {
27-
"@react-native-community/netinfo": "~4.1.0"
35+
"peerDependencies": {
36+
"@react-native-community/netinfo": "^4.1.0"
2837
}
2938
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"bs-react-native-example",
4747
"reason-react-navigation",
4848
"reason-react-navigation-example",
49+
"@reason-react-native/*",
4950
"website"
5051
]
5152
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,11 @@
16011601
resolved "https://registry.yarnpkg.com/@react-native-community/netinfo/-/netinfo-2.0.10.tgz#d28a446352e75754b78509557988359133cdbcca"
16021602
integrity sha512-NrIzyLe0eSbhgMnHl2QdSEhaA7yXh6p9jzMomfUa//hoTXE+xbObGDdiWWSQm2bnXnZJg8XCU3AB9qzvqcuLnA==
16031603

1604+
"@react-native-community/netinfo@^4.1.0":
1605+
version "4.1.5"
1606+
resolved "https://registry.yarnpkg.com/@react-native-community/netinfo/-/netinfo-4.1.5.tgz#4bb44842db6a1a18f00a0f061b0e3dcc638f67dd"
1607+
integrity sha512-lagdZr9UiVAccNXYfTEj+aUcPCx9ykbMe9puffeIyF3JsRuMmlu3BjHYx1klUHX7wNRmFNC8qVP0puxUt1sZ0A==
1608+
16041609
"@react-navigation/core@~3.4.1":
16051610
version "3.4.2"
16061611
resolved "https://registry.yarnpkg.com/@react-navigation/core/-/core-3.4.2.tgz#bec563e94fde40fbab3730cdc97f22afbb2a1498"

0 commit comments

Comments
 (0)