1- # ` @reason -react-native/netinfo `
1+ # ` @rescript -react-native/netinfo `
22
3- [ ![ Build Status] ( https://github.com/reason -react-native/netinfo/workflows/Build/badge.svg )] ( https://github.com/reason -react-native/netinfo/actions )
4- [ ![ Version] ( https://img.shields.io/npm/v/@reason -react-native/netinfo.svg )] ( https://www.npmjs.com/@reason -react-native/netinfo )
5- [ ![ Chat ] ( https://img.shields.io/discord/235176658175262720.svg?logo=discord&colorb=blue )] ( https://reason-react-native.github.io/discord / )
3+ [ ![ Build Status] ( https://github.com/rescript -react-native/netinfo/workflows/Build/badge.svg )] ( https://github.com/rescript -react-native/netinfo/actions )
4+ [ ![ Version] ( https://img.shields.io/npm/v/@rescript -react-native/netinfo.svg )] ( https://www.npmjs.com/@rescript -react-native/netinfo )
5+ [ ![ ReScript Forum ] ( https://img.shields.io/discourse/posts?color=e6484f&label=ReScript%20Forum&server=https%3A%2F%2Fforum.rescript-lang.org )] ( https://forum.rescript-lang.org / )
66
7- [ ReScript] ( https://rescript-lang.org ) / [ Reason ] ( https://reasonml.github.io ) bindings for
7+ [ ReScript] ( https://rescript-lang.org ) bindings for
88[ ` @react-native-community/netinfo ` ] ( https://github.com/react-native-netinfo/react-native-netinfo ) .
99
1010Exposed as ` ReactNativeNetInfo ` module.
1111
12- ` @reason -react-native/netinfo ` X.y.\* means it's compatible with
12+ ` @rescript -react-native/netinfo ` X.y.\* means it's compatible with
1313` @react-native-community/netinfo ` X.y.\*
1414
1515## Installation
@@ -20,22 +20,22 @@ is properly installed & configured by following their installation instructions,
2020you can install the bindings:
2121
2222``` console
23- npm install @reason -react-native/netinfo
23+ npm install @rescript -react-native/netinfo
2424# or
25- yarn add @reason -react-native/netinfo
25+ yarn add @rescript -react-native/netinfo
2626```
2727
28- ` @reason -react-native/netinfo ` should be added to ` bs-dependencies ` in your
28+ ` @rescript -react-native/netinfo ` should be added to ` bs-dependencies ` in your
2929` bsconfig.json ` :
3030
3131``` diff
3232{
3333 //...
3434 "bs-dependencies": [
35- "reason- react",
36- "reason -react-native",
35+ "@rescript/ react",
36+ "rescript -react-native",
3737 // ...
38- + "@reason -react-native/netinfo"
38+ + "@rescript -react-native/netinfo"
3939 ],
4040 //...
4141}
@@ -86,7 +86,7 @@ Cellular generation of the current network connection. Valid values are:
8686
8787#### ` netInfoState `
8888
89- ``` reason
89+ ``` rescript
9090type netInfoState = {
9191 .
9292 "_type": netInfoStateType,
@@ -112,7 +112,7 @@ type netInfoState = {
112112` details ` depends on ` _type ` given within [ ` netInfoState ` ] ( #netInfoState ) . If
113113` _type ` is not ` null ` or ` unknown ` , ` details ` is an object as below:
114114
115- ``` reason
115+ ``` rescript
116116type details = {
117117 .
118118 "isConnectionExpensive": bool,
@@ -158,7 +158,7 @@ Note that some keys may only exist in the JS object when `_type` is `wifi` or
158158
159159#### ` configure `
160160
161- ``` reason
161+ ``` rescript
162162configure: netInfoConfiguration => unit
163163```
164164
@@ -167,14 +167,14 @@ configure: netInfoConfiguration => unit
167167To query state of the active connection, returns ` netInfoState ` wrapped in a
168168` Promise ` .
169169
170- ``` reason
170+ ``` rescript
171171fetch: unit => Js.Promise.t(netInfoState)
172172```
173173
174174Below example demonstrates determination of the cellular connection generation,
175175using this method.
176176
177- ``` reason
177+ ``` rescript
178178React.useEffect0(() => {
179179 Js.Promise.(
180180 ReactNativeNetInfo.fetch()
@@ -216,7 +216,7 @@ React.useEffect0(() => {
216216
217217To query the connection state for a particular interface.
218218
219- ``` reason
219+ ``` rescript
220220fetchInterface: [ | `cellular | `ethernet | `wifi] => Js.Promise.t(netInfoState)
221221```
222222
@@ -227,19 +227,19 @@ To subscribe to the connection state; accepts a listener of type
227227The listener will be called once following subscription and each time connection
228228state changes.
229229
230- ``` reason
230+ ``` rescript
231231addEventListener: (netInfoState => unit) => t
232232```
233233
234234where
235235
236- ``` reason
236+ ``` rescript
237237type t = unit => unit
238238```
239239
240240Below example demonstrates subscribing to changes in connection state:
241241
242- ``` reason
242+ ``` rescript
243243React.useEffect0(() => {
244244 let remove =
245245 ReactNativeNetInfo.addEventListener(w =>
@@ -277,13 +277,13 @@ React.useEffect0(() => {
277277
278278This method returns a React Hook with type ` netInfoState `
279279
280- ``` reason
280+ ``` rescript
281281useNetInfo: unit => netInfoState
282282```
283283
284284Below example demonstrates its use within a ` Text ` component:
285285
286- ``` reason
286+ ``` rescript
287287<Text>
288288 (
289289 switch (ReactNativeNetInfo.useNetInfo()##details->Js.Null.toOption) {
@@ -324,11 +324,11 @@ releases.
324324## Contribute
325325
326326Read the
327- [ contribution guidelines] ( https://github.com/reason -react-native/.github/blob/master/CONTRIBUTING.md )
327+ [ contribution guidelines] ( https://github.com/rescript -react-native/.github/blob/master/CONTRIBUTING.md )
328328before contributing.
329329
330330## Code of Conduct
331331
332332We want this community to be friendly and respectful to each other. Please read
333- [ our full code of conduct] ( https://github.com/reason -react-native/.github/blob/master/CODE_OF_CONDUCT.md )
333+ [ our full code of conduct] ( https://github.com/rescript -react-native/.github/blob/master/CODE_OF_CONDUCT.md )
334334so that you can understand what actions will and will not be tolerated.
0 commit comments