Skip to content

Commit e59c602

Browse files
authored
Guides: migrate blockquote notes to admonitions (#4725)
1 parent c521676 commit e59c602

13 files changed

+144
-54
lines changed

docs/building-for-tv.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ hide_table_of_contents: true
66

77
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.
88

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.
11+
:::

docs/communication-android.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ It is fine to update properties anytime. However, updates have to be performed o
114114

115115
There is no way to update only a few properties at a time. We suggest that you build it into your own wrapper instead.
116116

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+
:::
118120

119121
### Passing properties from React Native to native
120122

@@ -146,4 +148,6 @@ Events are powerful, because they allow us to change React Native components wit
146148

147149
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).
148150

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.
153+
:::

docs/integration-with-android-fragment.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ This is required by React Native to handle the back button press event.
3333

3434
Go into your host activity and make sure it implements the `DefaultHardwareBackBtnHandler` interface:
3535

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.
38+
:::
3739

3840
<Tabs groupId="android-language" queryString defaultValue={constants.defaultAndroidLanguage} values={constants.androidLanguages}>
3941
<TabItem value="kotlin">

docs/intro-react.md

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ const Cat = () => {
6565
export default Cat;
6666
```
6767

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+
:::
6971

7072
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.
7173

@@ -132,7 +134,9 @@ export default Cat;
132134

133135
You can think of curly braces as creating a portal into JS functionality in your JSX!
134136

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+
:::
136140

137141
## Custom Components
138142

@@ -169,12 +173,16 @@ export default Cat;
169173

170174
<TabItem value="web">
171175

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+
:::
173179

174180
</TabItem>
175181
<TabItem value="android">
176182

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+
:::
178186

179187
</TabItem>
180188
</Tabs>
@@ -303,15 +311,19 @@ export default CatApp;
303311

304312
`Image` has [many different props](image#props), including [`style`](image#style), which accepts a JS object of design and layout related property-value pairs.
305313

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+
:::
307317

308318
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.
309319

310320
## State
311321

312322
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!
313323

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+
:::
315327

316328
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.
317329

@@ -415,7 +427,9 @@ const Cat = (props: CatProps) => {
415427
};
416428
```
417429

418-
> 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+
:::
419433

420434
Calling `useState` does two things:
421435

@@ -445,7 +459,9 @@ Now, when someone presses the button, `onPress` will fire, calling the `setIsHun
445459
/>
446460
```
447461

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+
:::
449465

450466
Finally, put your cats inside a `Cafe` component:
451467

@@ -460,7 +476,9 @@ const Cafe = () => {
460476
};
461477
```
462478

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`.
481+
:::
464482

465483
---
466484

docs/introduction.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ You can start here and read through these docs linearly like a book; or you can
2121

2222
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.
2323

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+
:::
2527

2628
## Interactive examples
2729

@@ -49,7 +51,9 @@ export default YourApp;
4951

5052
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!"
5153

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+
:::
5357

5458
## Developer Notes
5559

@@ -59,17 +63,23 @@ People from many different development backgrounds are learning React Native. Yo
5963

6064
<TabItem value="android">
6165

62-
> Android developers may be familiar with this concept.
66+
:::info
67+
Android developers may be familiar with this concept.
68+
:::
6369

6470
</TabItem>
6571
<TabItem value="ios">
6672

67-
> iOS developers may be familiar with this concept.
73+
:::info
74+
iOS developers may be familiar with this concept.
75+
:::
6876

6977
</TabItem>
7078
<TabItem value="web">
7179

72-
> Web developers may be familiar with this concept.
80+
:::info
81+
Web developers may be familiar with this concept.
82+
:::
7383

7484
</TabItem>
7585
</Tabs>

docs/libraries.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ React Native libraries are typically installed from the [npm registry](https://w
1616

1717
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.
1818

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.
21+
:::
2022

2123
## Installing a Library
2224

docs/network.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,13 @@ export default App;
181181
</TabItem>
182182
</Tabs>
183183

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+
:::
185187

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.
190+
:::
187191

188192
## Using Other Networking Libraries
189193

@@ -207,7 +211,9 @@ request.open('GET', 'https://mywebsite.com/endpoint/');
207211
request.send();
208212
```
209213

210-
> 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.
216+
:::
211217

212218
## WebSocket Support
213219

docs/optimizing-javascript-loading.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ See the documentation for [`getTransformOptions` in Metro](https://metrobundler.
175175

176176
## Advanced: Use random access module bundles (non-Hermes)
177177

178-
:::info
178+
:::tip
179179
**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.
180180
:::
181181

0 commit comments

Comments
 (0)