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/_getting-started-linux-android.md
+18-6Lines changed: 18 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,9 @@ Setting up your development environment can be somewhat tedious if you're new to
26
26
27
27
Then, click "Next" to install all of these components.
28
28
29
-
> If the checkboxes are grayed out, you will have a chance to install these components later on.
29
+
:::note
30
+
If the checkboxes are grayed out, you will have a chance to install these components later on.
31
+
:::
30
32
31
33
Once setup has finalized and you're presented with the Welcome screen, proceed to the next step.
32
34
@@ -36,7 +38,9 @@ Android Studio installs the latest Android SDK by default. Building a React Nati
36
38
37
39
To do that, open Android Studio, click on "Configure" button and select "SDK Manager".
38
40
39
-
> The SDK Manager can also be found within the Android Studio "Settings" dialog, under **Languages & Frameworks** → **Android SDK**.
41
+
:::tip
42
+
The SDK Manager can also be found within the Android Studio "Settings" dialog, under **Languages & Frameworks** → **Android SDK**.
43
+
:::
40
44
41
45
Select the "SDK Platforms" tab from within the SDK Manager, then check the box next to "Show Package Details" in the bottom right corner. Look for and expand the `Android 15 (VanillaIceCream)` entry, then make sure the following items are checked:
> `.bash_profile` is specific to `bash`. If you're using another shell, you will need to edit the appropriate shell-specific config file.
66
+
:::note
67
+
`.bash_profile` is specific to `bash`. If you're using another shell, you will need to edit the appropriate shell-specific config file.
68
+
:::
63
69
64
70
Type `source $HOME/.bash_profile` for `bash` or `source $HOME/.zprofile` to load the config into your current shell. Verify that ANDROID_HOME has been set by running `echo $ANDROID_HOME` and the appropriate directories have been added to your path by running `echo $PATH`.
65
71
66
-
> Please make sure you use the correct Android SDK path. You can find the actual location of the SDK in the Android Studio "Settings" dialog, under **Languages & Frameworks** → **Android SDK**.
72
+
:::note
73
+
Please make sure you use the correct Android SDK path. You can find the actual location of the SDK in the Android Studio "Settings" dialog, under **Languages & Frameworks** → **Android SDK**.
74
+
:::
67
75
68
76
<h3>Watchman</h3>
69
77
70
78
Follow the [Watchman installation guide](https://facebook.github.io/watchman/docs/install#buildinstall) to compile and install Watchman from source.
71
79
72
-
> [Watchman](https://facebook.github.io/watchman/docs/install) is a tool by Facebook for watching changes in the filesystem. It is highly recommended you install it for better performance and increased compatibility in certain edge cases (translation: you may be able to get by without installing this, but your mileage may vary; installing this now may save you from a headache later).
80
+
:::info
81
+
[Watchman](https://facebook.github.io/watchman/docs/install) is a tool by Facebook for watching changes in the filesystem. It is highly recommended you install it for better performance and increased compatibility in certain edge cases (translation: you may be able to get by without installing this, but your mileage may vary; installing this now may save you from a headache later).
82
+
:::
73
83
74
84
<h2>Preparing the Android device</h2>
75
85
@@ -89,7 +99,9 @@ If you use Android Studio to open `./AwesomeProject/android`, you can see the li
89
99
90
100
If you have recently installed Android Studio, you will likely need to [create a new AVD](https://developer.android.com/studio/run/managing-avds.html). Select "Create Virtual Device...", then pick any Phone from the list and click "Next", then select the **VanillaIceCream** API Level 35 image.
91
101
92
-
> We recommend configuring [VM acceleration](https://developer.android.com/studio/run/emulator-acceleration.html#vm-linux) on your system to improve performance. Once you've followed those instructions, go back to the AVD Manager.
102
+
:::tip
103
+
We recommend configuring [VM acceleration](https://developer.android.com/studio/run/emulator-acceleration.html#vm-linux) on your system to improve performance. Once you've followed those instructions, go back to the AVD Manager.
104
+
:::
93
105
94
106
Click "Next" then "Finish" to create your AVD. At this point you should be able to click on the green triangle button next to your AVD to launch it.
Copy file name to clipboardExpand all lines: docs/_getting-started-macos-android.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
@@ -65,7 +65,9 @@ Setting up your development environment can be somewhat tedious if you're new to
65
65
66
66
Then, click "Next" to install all of these components.
67
67
68
-
> If the checkboxes are grayed out, you will have a chance to install these components later on.
68
+
::note
69
+
If the checkboxes are grayed out, you will have a chance to install these components later on.
70
+
:::
69
71
70
72
Once setup has finalized and you're presented with the Welcome screen, proceed to the next step.
71
73
@@ -77,7 +79,9 @@ To do that, open Android Studio, click on "More Actions" button and select "SDK
77
79
78
80

79
81
80
-
> The SDK Manager can also be found within the Android Studio "Settings" dialog, under **Languages & Frameworks** → **Android SDK**.
82
+
:::tip
83
+
The SDK Manager can also be found within the Android Studio "Settings" dialog, under **Languages & Frameworks** → **Android SDK**.
84
+
:::
81
85
82
86
Select the "SDK Platforms" tab from within the SDK Manager, then check the box next to "Show Package Details" in the bottom right corner. Look for and expand the `Android 15 (VanillaIceCream)` entry, then make sure the following items are checked:
Run `source ~/.zprofile` (or `source ~/.bash_profile` for `bash`) to load the config into your current shell. Verify that ANDROID_HOME has been set by running `echo $ANDROID_HOME` and the appropriate directories have been added to your path by running `echo $PATH`.
104
108
105
-
> Please make sure you use the correct Android SDK path. You can find the actual location of the SDK in the Android Studio "Settings" dialog, under **Languages & Frameworks** → **Android SDK**.
109
+
:::note
110
+
Please make sure you use the correct Android SDK path. You can find the actual location of the SDK in the Android Studio "Settings" dialog, under **Languages & Frameworks** → **Android SDK**.
If you have already installed Node on your system, make sure it is Node 18 or newer. If you already have a JDK on your system, we recommend JDK17. You may encounter problems using higher JDK versions.
22
22
23
-
> You can find additional installation options on [Node's Downloads page](https://nodejs.org/en/download/).
23
+
:::note
24
+
You can find additional installation options on [Node's Downloads page](https://nodejs.org/en/download/).
25
+
:::
24
26
25
-
> If you're using the latest version of Java Development Kit, you'll need to change the Gradle version of your project so it can recognize the JDK. You can do that by going to `{project root folder}\android\gradle\wrapper\gradle-wrapper.properties` and changing the `distributionUrl` value to upgrade the Gradle version. You can check out [here the latest releases of Gradle](https://gradle.org/releases/).
27
+
:::info
28
+
If you're using the latest version of Java Development Kit, you'll need to change the Gradle version of your project so it can recognize the JDK. You can do that by going to `{project root folder}\android\gradle\wrapper\gradle-wrapper.properties` and changing the `distributionUrl` value to upgrade the Gradle version. You can check out [here the latest releases of Gradle](https://gradle.org/releases/).
29
+
:::
26
30
27
31
<h3>Android development environment</h3>
28
32
@@ -39,7 +43,9 @@ Setting up your development environment can be somewhat tedious if you're new to
39
43
40
44
Then, click "Next" to install all of these components.
41
45
42
-
> If the checkboxes are grayed out, you will have a chance to install these components later on.
46
+
:::note
47
+
If the checkboxes are grayed out, you will have a chance to install these components later on.
48
+
:::
43
49
44
50
Once setup has finalized and you're presented with the Welcome screen, proceed to the next step.
45
51
@@ -51,7 +57,9 @@ To do that, open Android Studio, click on "More Actions" button and select "SDK
51
57
52
58

53
59
54
-
> The SDK Manager can also be found within the Android Studio "Settings" dialog, under **Languages & Frameworks** → **Android SDK**.
60
+
:::tip
61
+
The SDK Manager can also be found within the Android Studio "Settings" dialog, under **Languages & Frameworks** → **Android SDK**.
62
+
:::
55
63
56
64
Select the "SDK Platforms" tab from within the SDK Manager, then check the box next to "Show Package Details" in the bottom right corner. Look for and expand the `Android 15 (VanillaIceCream)` entry, then make sure the following items are checked:
57
65
@@ -120,7 +128,9 @@ If you use Android Studio to open `./AwesomeProject/android`, you can see the li
120
128
121
129
If you have recently installed Android Studio, you will likely need to [create a new AVD](https://developer.android.com/studio/run/managing-avds.html). Select "Create Virtual Device...", then pick any Phone from the list and click "Next", then select the **VanillaIceCream** API Level 35 image.
122
130
123
-
> If you don't have HAXM installed, click on "Install HAXM" or follow [these instructions](https://github.com/intel/haxm/wiki/Installation-Instructions-on-Windows) to set it up, then go back to the AVD Manager.
131
+
:::note
132
+
If you don't have HAXM installed, click on "Install HAXM" or follow [these instructions](https://github.com/intel/haxm/wiki/Installation-Instructions-on-Windows) to set it up, then go back to the AVD Manager.
133
+
:::
124
134
125
135
Click "Next" then "Finish" to create your AVD. At this point you should be able to click on the green triangle button next to your AVD to launch it.
Copy file name to clipboardExpand all lines: docs/flatlist.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
@@ -640,7 +640,9 @@ Set this true while waiting for new data from a refresh.
640
640
641
641
This may improve scroll performance for large lists. On Android the default value is `true`.
642
642
643
-
> Note: May have bugs (missing content) in some circumstances - use at your own risk.
643
+
:::warning
644
+
May have bugs (missing content) in some circumstances - use at your own risk.
645
+
:::
644
646
645
647
| Type |
646
648
| ------- |
@@ -787,7 +789,9 @@ scrollToIndex: (params: {
787
789
788
790
Scrolls to the item at the specified index such that it is positioned in the viewable area such that `viewPosition` 0 places it at the top, 1 at the bottom, and 0.5 centered in the middle.
789
791
790
-
> Note: Cannot scroll to locations outside the render window without specifying the `getItemLayout` prop.
792
+
:::note
793
+
Cannot scroll to locations outside the render window without specifying the `getItemLayout` prop.
794
+
:::
791
795
792
796
**Parameters:**
793
797
@@ -816,7 +820,9 @@ scrollToItem(params: {
816
820
817
821
Requires linear scan through data - use `scrollToIndex` instead if possible.
818
822
819
-
> Note: Cannot scroll to locations outside the render window without specifying the `getItemLayout` prop.
823
+
:::note
824
+
Cannot scroll to locations outside the render window without specifying the `getItemLayout` prop.
Copy file name to clipboardExpand all lines: docs/legacy/native-modules-android.md
+24-12Lines changed: 24 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,9 +77,11 @@ class CalendarModule(reactContext: ReactApplicationContext) : ReactContextBaseJa
77
77
78
78
As you can see, your `CalendarModule` class extends the `ReactContextBaseJavaModule` class. For Android, Java/Kotlin native modules are written as classes that extend `ReactContextBaseJavaModule` and implement the functionality required by JavaScript.
79
79
80
-
> It is worth noting that technically Java/Kotlin classes only need to extend the `BaseJavaModule` class or implement the `NativeModule` interface to be considered a Native Module by React Native.
80
+
:::note
81
+
It is worth noting that technically Java/Kotlin classes only need to extend the `BaseJavaModule` class or implement the `NativeModule` interface to be considered a Native Module by React Native.
81
82
82
-
> However we recommend that you use `ReactContextBaseJavaModule`, as shown above. `ReactContextBaseJavaModule` gives access to the `ReactApplicationContext` (RAC), which is useful for Native Modules that need to hook into activity lifecycle methods. Using `ReactContextBaseJavaModule` will also make it easier to make your native module type-safe in the future. For native module type-safety, which is coming in future releases, React Native looks at each native module's JavaScript spec and generates an abstract base class that extends `ReactContextBaseJavaModule`.
83
+
However we recommend that you use `ReactContextBaseJavaModule`, as shown above. `ReactContextBaseJavaModule` gives access to the `ReactApplicationContext` (RAC), which is useful for Native Modules that need to hook into activity lifecycle methods. Using `ReactContextBaseJavaModule` will also make it easier to make your native module type-safe in the future. For native module type-safety, which is coming in future releases, React Native looks at each native module's JavaScript spec and generates an abstract base class that extends `ReactContextBaseJavaModule`.
84
+
:::
83
85
84
86
### Module Name
85
87
@@ -267,7 +269,9 @@ class MyAppPackage : ReactPackage {
267
269
268
270
This file imports the native module you created, `CalendarModule`. It then instantiates `CalendarModule` within the `createNativeModules()` function and returns it as a list of `NativeModules` to register. If you add more native modules down the line, you can also instantiate them and add them to the list returned here.
269
271
270
-
> It is worth noting that this way of registering native modules eagerly initializes all native modules when the application starts, which adds to the startup time of an application. You can use [TurboReactPackage](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/TurboReactPackage.java) as an alternative. Instead of `createNativeModules`, which return a list of instantiated native module objects, TurboReactPackage implements a `getModule(String name, ReactApplicationContext rac)` method that creates the native module object, when required. TurboReactPackage is a bit more complicated to implement at the moment. In addition to implementing a `getModule()` method, you have to implement a `getReactModuleInfoProvider()` method, which returns a list of all the native modules the package can instantiate along with a function that instantiates them, example [here](https://github.com/facebook/react-native/blob/8ac467c51b94c82d81930b4802b2978c85539925/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java#L86-L165). Again, using TurboReactPackage will allow your application to have a faster startup time, but it is currently a bit cumbersome to write. So proceed with caution if you choose to use TurboReactPackages.
272
+
:::note
273
+
It is worth noting that this way of registering native modules eagerly initializes all native modules when the application starts, which adds to the startup time of an application. You can use [TurboReactPackage](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/TurboReactPackage.java) as an alternative. Instead of `createNativeModules`, which return a list of instantiated native module objects, TurboReactPackage implements a `getModule(String name, ReactApplicationContext rac)` method that creates the native module object, when required. TurboReactPackage is a bit more complicated to implement at the moment. In addition to implementing a `getModule()` method, you have to implement a `getReactModuleInfoProvider()` method, which returns a list of all the native modules the package can instantiate along with a function that instantiates them, example [here](https://github.com/facebook/react-native/blob/8ac467c51b94c82d81930b4802b2978c85539925/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java#L86-L165). Again, using TurboReactPackage will allow your application to have a faster startup time, but it is currently a bit cumbersome to write. So proceed with caution if you choose to use TurboReactPackages.
274
+
:::
271
275
272
276
To register the `CalendarModule` package, you must add `MyAppPackage` to the list of packages returned in ReactNativeHost's `getPackages()` method. Open up your `MainApplication.java` or `MainApplication.kt` file, which can be found in the following path: `android/app/src/main/java/com/your-app-name/`.
273
277
@@ -431,7 +435,9 @@ import CalendarModule from './CalendarModule';
431
435
CalendarModule.createCalendarEvent('foo', 'bar');
432
436
```
433
437
434
-
> This assumes that the place you are importing `CalendarModule` is in the same hierarchy as `CalendarModule.js`. Please update the relative import as necessary.
438
+
:::note
439
+
This assumes that the place you are importing `CalendarModule` is in the same hierarchy as `CalendarModule.js`. Please update the relative import as necessary.
440
+
:::
435
441
436
442
### Argument Types
437
443
@@ -449,12 +455,14 @@ When a native module method is invoked in JavaScript, React Native converts the
449
455
| ReadableMap | ReadableMap | Object |
450
456
| ReadableArray | ReadableArray | Array |
451
457
452
-
> The following types are currently supported but will not be supported in TurboModules. Please avoid using them:
453
-
>
454
-
> - Integer Java/Kotlin -> ?number
455
-
> - Float Java/Kotlin -> ?number
456
-
> - int Java -> number
457
-
> - float Java -> number
458
+
:::info
459
+
The following types are currently supported but will not be supported in TurboModules. Please avoid using them:
460
+
461
+
- Integer Java/Kotlin -> ?number
462
+
- Float Java/Kotlin -> ?number
463
+
- int Java -> number
464
+
- float Java -> number
465
+
:::
458
466
459
467
For argument types not listed above, you will need to handle the conversion yourself. For example, in Android, `Date` conversion is not supported out of the box. You can handle the conversion to the `Date` type within the native method yourself like so:
Technically it is possible to access constants exported in `getConstants()` directly off the native module object. This will no longer be supported with TurboModules, so we encourage the community to switch to the above approach to avoid necessary migration down the line.
526
534
527
-
> That currently constants are exported only at initialization time, so if you change getConstants values at runtime it won't affect the JavaScript environment. This will change with Turbomodules. With Turbomodules, `getConstants()` will become a regular native module method, and each invocation will hit the native side.
535
+
:::note
536
+
That currently constants are exported only at initialization time, so if you change getConstants values at runtime it won't affect the JavaScript environment. This will change with Turbomodules. With Turbomodules, `getConstants()` will become a regular native module method, and each invocation will hit the native side.
> Similar to callbacks, a native module method can either reject or resolve a promise (but not both) and can do so at most once. This means that you can either call a success callback or a failure callback, but not both, and each callback can only be invoked at most one time. A native module can, however, store the callback and invoke it later.
742
+
:::note
743
+
Similar to callbacks, a native module method can either reject or resolve a promise (but not both) and can do so at most once. This means that you can either call a success callback or a failure callback, but not both, and each callback can only be invoked at most one time. A native module can, however, store the callback and invoke it later.
744
+
:::
733
745
734
746
The JavaScript counterpart of this method returns a Promise. This means you can use the `await` keyword within an async function to call it and wait for its result:
0 commit comments