You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/network.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,13 +15,13 @@ React Native provides the [Fetch API](https://developer.mozilla.org/en-US/docs/W
15
15
16
16
In order to fetch content from an arbitrary URL, you can pass the URL to fetch:
17
17
18
-
```tsx
18
+
```ts
19
19
fetch('https://mywebsite.com/mydata.json');
20
20
```
21
21
22
22
Fetch also takes an optional second argument that allows you to customize the HTTP request. You may want to specify additional headers, or make a POST request:
23
23
24
-
```tsx
24
+
```ts
25
25
fetch('https://mywebsite.com/endpoint/', {
26
26
method: 'POST',
27
27
headers: {
@@ -43,7 +43,7 @@ The above examples show how you can make a request. In many cases, you will want
43
43
44
44
Networking is an inherently asynchronous operation. Fetch method will return a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that makes it straightforward to write code that works in an asynchronous manner:
You can also use the `async` / `await` syntax in a React Native app:
60
60
61
-
```tsx
61
+
```ts
62
62
const getMoviesFromApiAsync =async () => {
63
63
try {
64
64
const response =awaitfetch(
@@ -199,7 +199,7 @@ On Android, as of API Level 28, clear text traffic is also blocked by default. T
199
199
200
200
The [XMLHttpRequest API](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) is built into React Native. This means that you can use third party libraries such as [frisbee](https://github.com/niftylettuce/frisbee) or [axios](https://github.com/axios/axios) that depend on it, or you can use the XMLHttpRequest API directly if you prefer.
201
201
202
-
```tsx
202
+
```ts
203
203
const request =newXMLHttpRequest();
204
204
request.onreadystatechange=e=> {
205
205
if (request.readyState!==4) {
@@ -225,7 +225,7 @@ The security model for XMLHttpRequest is different than on web as there is no co
225
225
226
226
React Native also supports [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket), a protocol which provides full-duplex communication channels over a single TCP connection.
Copy file name to clipboardExpand all lines: docs/timers.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ One reason why well-built native apps feel so smooth is by avoiding expensive op
33
33
34
34
Applications can schedule tasks to run after interactions with the following:
35
35
36
-
```tsx
36
+
```ts
37
37
InteractionManager.runAfterInteractions(() => {
38
38
// ...long-running synchronous task...
39
39
});
@@ -49,7 +49,7 @@ The touch handling system considers one or more active touches to be an 'interac
49
49
50
50
`InteractionManager` also allows applications to register animations by creating an interaction 'handle' on animation start, and clearing it upon completion:
Copy file name to clipboardExpand all lines: website/versioned_docs/version-0.77/network.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,13 +15,13 @@ React Native provides the [Fetch API](https://developer.mozilla.org/en-US/docs/W
15
15
16
16
In order to fetch content from an arbitrary URL, you can pass the URL to fetch:
17
17
18
-
```tsx
18
+
```ts
19
19
fetch('https://mywebsite.com/mydata.json');
20
20
```
21
21
22
22
Fetch also takes an optional second argument that allows you to customize the HTTP request. You may want to specify additional headers, or make a POST request:
23
23
24
-
```tsx
24
+
```ts
25
25
fetch('https://mywebsite.com/endpoint/', {
26
26
method: 'POST',
27
27
headers: {
@@ -43,7 +43,7 @@ The above examples show how you can make a request. In many cases, you will want
43
43
44
44
Networking is an inherently asynchronous operation. Fetch method will return a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that makes it straightforward to write code that works in an asynchronous manner:
You can also use the `async` / `await` syntax in a React Native app:
60
60
61
-
```tsx
61
+
```ts
62
62
const getMoviesFromApiAsync =async () => {
63
63
try {
64
64
const response =awaitfetch(
@@ -189,7 +189,7 @@ export default App;
189
189
190
190
The [XMLHttpRequest API](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) is built into React Native. This means that you can use third party libraries such as [frisbee](https://github.com/niftylettuce/frisbee) or [axios](https://github.com/axios/axios) that depend on it, or you can use the XMLHttpRequest API directly if you prefer.
191
191
192
-
```tsx
192
+
```ts
193
193
const request =newXMLHttpRequest();
194
194
request.onreadystatechange=e=> {
195
195
if (request.readyState!==4) {
@@ -213,7 +213,7 @@ request.send();
213
213
214
214
React Native also supports [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket), a protocol which provides full-duplex communication channels over a single TCP connection.
Copy file name to clipboardExpand all lines: website/versioned_docs/version-0.77/timers.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ One reason why well-built native apps feel so smooth is by avoiding expensive op
29
29
30
30
Applications can schedule tasks to run after interactions with the following:
31
31
32
-
```tsx
32
+
```ts
33
33
InteractionManager.runAfterInteractions(() => {
34
34
// ...long-running synchronous task...
35
35
});
@@ -45,7 +45,7 @@ The touch handling system considers one or more active touches to be an 'interac
45
45
46
46
InteractionManager also allows applications to register animations by creating an interaction 'handle' on animation start, and clearing it upon completion:
0 commit comments