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/building-for-tv.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,4 +6,6 @@ hide_table_of_contents: true
6
6
7
7
TV devices support has been implemented with the intention of making existing React Native applications work on Apple TV and Android TV, with few or no changes needed in the JavaScript code for the applications.
8
8
9
-
> **Deprecated.** TV support has moved to the [React Native for TV](https://github.com/react-native-tvos/react-native-tvos#readme) repository. Please see the _README_ there for information on projects for Apple TV or Android TV.
9
+
:::warning Deprecated
10
+
TV support has moved to the [React Native for TV](https://github.com/react-native-tvos/react-native-tvos#readme) repository. Please see the **README** there for information on projects for Apple TV or Android TV.
Copy file name to clipboardExpand all lines: docs/communication-android.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,7 +114,9 @@ It is fine to update properties anytime. However, updates have to be performed o
114
114
115
115
There is no way to update only a few properties at a time. We suggest that you build it into your own wrapper instead.
116
116
117
-
> **_Note:_** Currently, JS function `componentWillUpdateProps` of the top level RN component will not be called after a prop update. However, you can access the new props in `componentDidMount` function.
117
+
:::info
118
+
Currently, JS function `componentWillUpdateProps` of the top level RN component will not be called after a prop update. However, you can access the new props in `componentDidMount` function.
119
+
:::
118
120
119
121
### Passing properties from React Native to native
120
122
@@ -146,4 +148,6 @@ Events are powerful, because they allow us to change React Native components wit
146
148
147
149
Native modules are Java/Kotlin classes that are available in JS. Typically one instance of each module is created per JS bridge. They can export arbitrary functions and constants to React Native. They have been covered in detail in [this article](legacy/native-modules-android).
148
150
149
-
> **_Warning_**: All native modules share the same namespace. Watch out for name collisions when creating new ones.
151
+
:::warning
152
+
All native modules share the same namespace. Watch out for name collisions when creating new ones.
Copy file name to clipboardExpand all lines: docs/integration-with-android-fragment.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,9 @@ This is required by React Native to handle the back button press event.
33
33
34
34
Go into your host activity and make sure it implements the `DefaultHardwareBackBtnHandler` interface:
35
35
36
-
> **Deprecated.**`Activity.onBackPressed()` has been [deprecated](<https://developer.android.com/reference/android/app/Activity#onBackPressed()>) since API level 33. Android 16 devices with apps targeting API level 36 this will [no longer be called](https://developer.android.com/about/versions/16/behavior-changes-16#predictive-back) and [OnBackPressedDispatcher](https://developer.android.com/reference/androidx/activity/OnBackPressedDispatcher) should be used instead.
36
+
:::warning Deprecated
37
+
`Activity.onBackPressed()` has been [deprecated](<https://developer.android.com/reference/android/app/Activity#onBackPressed()>) since API level 33. Android 16 devices with apps targeting API level 36 this will [no longer be called](https://developer.android.com/about/versions/16/behavior-changes-16#predictive-back) and [OnBackPressedDispatcher](https://developer.android.com/reference/androidx/activity/OnBackPressedDispatcher) should be used instead.
Copy file name to clipboardExpand all lines: docs/intro-react.md
+27-9Lines changed: 27 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,9 @@ const Cat = () => {
65
65
exportdefaultCat;
66
66
```
67
67
68
-
> This is one of many ways to export your component. This kind of export works well with the Snack Player. However, depending on your app’s file structure, you might need to use a different convention. This [handy cheatsheet on JavaScript imports and exports](https://medium.com/dailyjs/javascript-module-cheatsheet-7bd474f1d829) can help.
68
+
:::tip
69
+
This is one of many ways to export your component. This kind of export works well with the Snack Player. However, depending on your app’s file structure, you might need to use a different convention. This [handy cheatsheet on JavaScript imports and exports](https://medium.com/dailyjs/javascript-module-cheatsheet-7bd474f1d829) can help.
70
+
:::
69
71
70
72
Now take a closer look at that `return` statement. `<Text>Hello, I am your cat!</Text>` is using a kind of JavaScript syntax that makes writing elements convenient: JSX.
71
73
@@ -132,7 +134,9 @@ export default Cat;
132
134
133
135
You can think of curly braces as creating a portal into JS functionality in your JSX!
134
136
135
-
> Because JSX is included in the React library, it won’t work if you don’t have `import React from 'react'` at the top of your file!
137
+
:::tip
138
+
Because JSX is included in the React library, it won’t work if you don’t have `import React from 'react'` at the top of your file!
139
+
:::
136
140
137
141
## Custom Components
138
142
@@ -169,12 +173,16 @@ export default Cat;
169
173
170
174
<TabItemvalue="web">
171
175
172
-
> If you’re familiar with web development, `<View>` and `<Text>` might remind you of HTML! You can think of them as the `<div>` and `<p>` tags of application development.
176
+
:::info
177
+
If you’re familiar with web development, `<View>` and `<Text>` might remind you of HTML! You can think of them as the `<div>` and `<p>` tags of application development.
178
+
:::
173
179
174
180
</TabItem>
175
181
<TabItemvalue="android">
176
182
177
-
> On Android, you usually put your views inside `LinearLayout`, `FrameLayout`, `RelativeLayout`, etc. to define how the view’s children will be arranged on the screen. In React Native, `View` uses Flexbox for its children’s layout. You can learn more in [our guide to layout with Flexbox](flexbox).
183
+
:::info
184
+
On Android, you usually put your views inside `LinearLayout`, `FrameLayout`, `RelativeLayout`, etc. to define how the view’s children will be arranged on the screen. In React Native, `View` uses Flexbox for its children’s layout. You can learn more in [our guide to layout with Flexbox](flexbox).
185
+
:::
178
186
179
187
</TabItem>
180
188
</Tabs>
@@ -303,15 +311,19 @@ export default CatApp;
303
311
304
312
`Image` has [many different props](image#props), including [`style`](image#style), which accepts a JS object of design and layout related property-value pairs.
305
313
306
-
> Notice the double curly braces `{{ }}` surrounding `style`‘s width and height. In JSX, JavaScript values are referenced with `{}`. This is handy if you are passing something other than a string as props, like an array or number: `<Cat food={["fish", "kibble"]} age={2} />`. However, JS objects are **_also_** denoted with curly braces: `{width: 200, height: 200}`. Therefore, to pass a JS object in JSX, you must wrap the object in **another pair** of curly braces: `{{width: 200, height: 200}}`
314
+
:::note
315
+
Notice the double curly braces `{{ }}` surrounding `style`‘s width and height. In JSX, JavaScript values are referenced with `{}`. This is handy if you are passing something other than a string as props, like an array or number: `<Cat food={["fish", "kibble"]} age={2} />`. However, JS objects are **_also_** denoted with curly braces: `{width: 200, height: 200}`. Therefore, to pass a JS object in JSX, you must wrap the object in **another pair** of curly braces: `{{width: 200, height: 200}}`
316
+
:::
307
317
308
318
You can build many things with props and the Core Components [`Text`](text), [`Image`](image), and [`View`](view)! But to build something interactive, you’ll need state.
309
319
310
320
## State
311
321
312
322
While you can think of props as arguments you use to configure how components render, **state** is like a component’s personal data storage. State is useful for handling data that changes over time or that comes from user interaction. State gives your components memory!
313
323
314
-
> As a general rule, use props to configure a component when it renders. Use state to keep track of any component data that you expect to change over time.
324
+
:::info
325
+
As a general rule, use props to configure a component when it renders. Use state to keep track of any component data that you expect to change over time.
326
+
:::
315
327
316
328
The following example takes place in a cat cafe where two hungry cats are waiting to be fed. Their hunger, which we expect to change over time (unlike their names), is stored as state. To feed the cats, press their buttons—which will update their state.
> You can use `useState` to track any kind of data: strings, numbers, Booleans, arrays, objects. For example, you can track the number of times a cat has been petted with `const [timesPetted, setTimesPetted] = useState(0)`!
430
+
:::tip
431
+
You can use `useState` to track any kind of data: strings, numbers, Booleans, arrays, objects. For example, you can track the number of times a cat has been petted with `const [timesPetted, setTimesPetted] = useState(0)`!
432
+
:::
419
433
420
434
Calling `useState` does two things:
421
435
@@ -445,7 +459,9 @@ Now, when someone presses the button, `onPress` will fire, calling the `setIsHun
445
459
/>
446
460
```
447
461
448
-
> You might’ve noticed that although `isHungry` is a [const](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/const), it is seemingly reassignable! What is happening is when a state-setting function like `setIsHungry` is called, its component will re-render. In this case the `Cat` function will run again—and this time, `useState` will give us the next value of `isHungry`.
462
+
:::info
463
+
You might’ve noticed that although `isHungry` is a [const](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/const), it is seemingly reassignable! What is happening is when a state-setting function like `setIsHungry` is called, its component will re-render. In this case the `Cat` function will run again—and this time, `useState` will give us the next value of `isHungry`.
464
+
:::
449
465
450
466
Finally, put your cats inside a `Cafe` component:
451
467
@@ -460,7 +476,9 @@ const Cafe = () => {
460
476
};
461
477
```
462
478
463
-
> See the `<>` and `</>` above? These bits of JSX are [fragments](https://react.dev/reference/react/Fragment). Adjacent JSX elements must be wrapped in an enclosing tag. Fragments let you do that without nesting an extra, unnecessary wrapping element like `View`.
479
+
:::info
480
+
See the `<>` and `</>` above? These bits of JSX are [fragments](https://react.dev/reference/react/Fragment). Adjacent JSX elements must be wrapped in an enclosing tag. Fragments let you do that without nesting an extra, unnecessary wrapping element like `View`.
Copy file name to clipboardExpand all lines: docs/introduction.md
+15-5Lines changed: 15 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,9 @@ You can start here and read through these docs linearly like a book; or you can
21
21
22
22
To work with React Native, you will need to have an understanding of JavaScript fundamentals. If you’re new to JavaScript or need a refresher, you can [dive in](https://developer.mozilla.org/en-US/docs/Web/JavaScript) or [brush up](https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript) at Mozilla Developer Network.
23
23
24
-
> While we do our best to assume no prior knowledge of React, Android, or iOS development, these are valuable topics of study for the aspiring React Native developer. Where sensible, we have linked to resources and articles that go more in depth.
24
+
:::info
25
+
While we do our best to assume no prior knowledge of React, Android, or iOS development, these are valuable topics of study for the aspiring React Native developer. Where sensible, we have linked to resources and articles that go more in depth.
26
+
:::
25
27
26
28
## Interactive examples
27
29
@@ -49,7 +51,9 @@ export default YourApp;
49
51
50
52
The above is a Snack Player. It’s a handy tool created by Expo to embed and run React Native projects and share how they render in platforms like Android and iOS. The code is live and editable, so you can play directly with it in your browser. Go ahead and try changing the "Try editing me!" text above to "Hello, world!"
51
53
52
-
> Optionally, if you want to set up a local development environment, [you can follow our guide to setting up your environment on your local machine](set-up-your-environment) and paste the code examples into your project. (If you are a web developer, you may already have a local environment set up for mobile browser testing!)
54
+
:::tip
55
+
Optionally, if you want to set up a local development environment, [you can follow our guide to setting up your environment on your local machine](set-up-your-environment) and paste the code examples into your project. (If you are a web developer, you may already have a local environment set up for mobile browser testing!)
56
+
:::
53
57
54
58
## Developer Notes
55
59
@@ -59,17 +63,23 @@ People from many different development backgrounds are learning React Native. Yo
59
63
60
64
<TabItemvalue="android">
61
65
62
-
> Android developers may be familiar with this concept.
66
+
:::info
67
+
Android developers may be familiar with this concept.
68
+
:::
63
69
64
70
</TabItem>
65
71
<TabItemvalue="ios">
66
72
67
-
> iOS developers may be familiar with this concept.
73
+
:::info
74
+
iOS developers may be familiar with this concept.
75
+
:::
68
76
69
77
</TabItem>
70
78
<TabItemvalue="web">
71
79
72
-
> Web developers may be familiar with this concept.
Copy file name to clipboardExpand all lines: docs/libraries.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,9 @@ React Native libraries are typically installed from the [npm registry](https://w
16
16
17
17
If you have Node.js installed on your computer then you already have the npm CLI installed. Some developers prefer to use Yarn Classic for slightly faster install times and additional advanced features like Workspaces. Both tools work great with React Native. We will assume npm for the rest of this guide for simplicity of explanation.
18
18
19
-
> 💡 The terms "library" and "package" are used interchangeably in the JavaScript community.
19
+
:::note
20
+
The terms "library" and "package" are used interchangeably in the JavaScript community.
Copy file name to clipboardExpand all lines: docs/network.md
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -181,9 +181,13 @@ export default App;
181
181
</TabItem>
182
182
</Tabs>
183
183
184
-
> By default, iOS 9.0 or later enforce App Transport Security (ATS). ATS requires any HTTP connection to use HTTPS. If you need to fetch from a cleartext URL (one that begins with `http`) you will first need to [add an ATS exception](integration-with-existing-apps.md#test-your-integration). If you know ahead of time what domains you will need access to, it is more secure to add exceptions only for those domains; if the domains are not known until runtime you can [disable ATS completely](publishing-to-app-store.md#1-enable-app-transport-security). Note however that from January 2017, [Apple's App Store review will require reasonable justification for disabling ATS](https://forums.developer.apple.com/thread/48979). See [Apple's documentation](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33) for more information.
184
+
:::info
185
+
By default, iOS 9.0 or later enforce App Transport Security (ATS). ATS requires any HTTP connection to use HTTPS. If you need to fetch from a cleartext URL (one that begins with `http`) you will first need to [add an ATS exception](integration-with-existing-apps.md#test-your-integration). If you know ahead of time what domains you will need access to, it is more secure to add exceptions only for those domains; if the domains are not known until runtime you can [disable ATS completely](publishing-to-app-store.md#1-enable-app-transport-security). Note however that from January 2017, [Apple's App Store review will require reasonable justification for disabling ATS](https://forums.developer.apple.com/thread/48979). See [Apple's documentation](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33) for more information.
186
+
:::
185
187
186
-
> On Android, as of API Level 28, clear text traffic is also blocked by default. This behaviour can be overridden by setting [`android:usesCleartextTraffic`](https://developer.android.com/guide/topics/manifest/application-element#usesCleartextTraffic) in the app manifest file.
188
+
:::tip
189
+
On Android, as of API Level 28, clear text traffic is also blocked by default. This behaviour can be overridden by setting [`android:usesCleartextTraffic`](https://developer.android.com/guide/topics/manifest/application-element#usesCleartextTraffic) in the app manifest file.
> The security model for XMLHttpRequest is different than on web as there is no concept of [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) in native apps.
214
+
:::warning Caution
215
+
The security model for XMLHttpRequest is different than on web as there is no concept of [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) in native apps.
Copy file name to clipboardExpand all lines: docs/optimizing-javascript-loading.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -175,7 +175,7 @@ See the documentation for [`getTransformOptions` in Metro](https://metrobundler.
175
175
176
176
## Advanced: Use random access module bundles (non-Hermes)
177
177
178
-
:::info
178
+
:::tip
179
179
**Not supported when [using Hermes](#use-hermes).** Hermes bytecode is not compatible with the RAM bundle format, and provides the same (or better) performance in all use cases.
0 commit comments