Skip to content

Commit 909f91e

Browse files
authored
Merge branch 'main' into patch-1
2 parents bda9a0c + 83d6a2b commit 909f91e

File tree

484 files changed

+95226
-2184
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

484 files changed

+95226
-2184
lines changed

.alexrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ exports.allow = [
2121

2222
// allowing this term to prevent reporting "primitive", which is a programming term
2323
'savage',
24+
25+
// allowing this term, since it seems to be used not in insensitive cases
26+
'straightforward',
2427
];
2528

2629
// Use a "maybe" level of profanity instead of the default "unlikely".

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,8 @@ website/build/
3535
!.yarn/plugins
3636
!.yarn/releases
3737
!.yarn/sdks
38-
!.yarn/versions
38+
!.yarn/versions
39+
40+
41+
# Generated file(s) for llms
42+
llms.txt

docs/_integration-with-existing-apps-ios.md

Lines changed: 137 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ curl -O https://raw.githubusercontent.com/react-native-community/template/refs/h
115115
Please use the Community Template as a reference point for the [Gemfile](https://github.com/react-native-community/template/blob/0.78-stable/template/Gemfile) and for the [Podfile](https://github.com/react-native-community/template/blob/0.78-stable/template/ios/Podfile).
116116

117117
:::note
118-
Remember to change [this line](https://github.com/react-native-community/template/blob/0.78-stable/template/ios/Podfile#L17) and [this line](https://github.com/react-native-community/template/blob/0.78-stable/template/ios/Podfile#L26) of the Podfile to match the name of your app.
119-
120-
If your app don't have tests, remember to remove [this block](https://github.com/react-native-community/template/blob/0.78-stable/template/ios/Podfile#L26-L29).
118+
Remember to change [this line](https://github.com/react-native-community/template/blob/0.78-stable/template/ios/Podfile#L17).
121119
:::
122120

123121
Now, we need to run a couple of extra commands to install the Ruby gems and the Pods.
@@ -258,6 +256,8 @@ Now open the `ReactViewController.m` file and apply the following changes
258256
+#import <React/RCTBundleURLProvider.h>
259257
+#import <RCTReactNativeFactory.h>
260258
+#import <RCTDefaultReactNativeFactoryDelegate.h>
259+
+#import <RCTAppDependencyProvider.h>
260+
261261

262262
@interface ReactViewController ()
263263

@@ -275,7 +275,8 @@ Now open the `ReactViewController.m` file and apply the following changes
275275
- (void)viewDidLoad {
276276
[super viewDidLoad];
277277
// Do any additional setup after loading the view.
278-
+ _factoryDelegate = [ReactNativeDelegate new];
278+
+ _factoryDelegate = [ReactNativeFactoryDelegate new];
279+
+ _factoryDelegate.dependencyProvider = [RCTAppDependencyProvider new];
279280
+ _factory = [[RCTReactNativeFactory alloc] initWithDelegate:_factoryDelegate];
280281
+ self.view = [_factory.rootViewFactory viewWithModuleName:@"HelloWorld"];
281282
}
@@ -311,6 +312,7 @@ Now open the `ReactViewController.swift` file and apply the following changes
311312
import UIKit
312313
+import React
313314
+import React_RCTAppDelegate
315+
+import ReactAppDependencyProvider
314316

315317
class ReactViewController: UIViewController {
316318
+ var reactNativeFactory: RCTReactNativeFactory?
@@ -319,6 +321,7 @@ class ReactViewController: UIViewController {
319321
override func viewDidLoad() {
320322
super.viewDidLoad()
321323
+ reactNativeFactoryDelegate = ReactNativeDelegate()
324+
+ reactNativeFactoryDelegate!.dependencyProvider = RCTAppDependencyProvider()
322325
+ reactNativeFactory = RCTReactNativeFactory(delegate: reactNativeFactoryDelegate!)
323326
+ view = reactNativeFactory!.rootViewFactory.view(withModuleName: "HelloWorld")
324327

@@ -513,6 +516,135 @@ REACT_NATIVE_XCODE="$REACT_NATIVE_PATH/scripts/react-native-xcode.sh"
513516

514517
Now, if you build your app for Release, it will work as expected.
515518

516-
### Now what?
519+
## 7. Passing initial props to the React Native view
520+
521+
In some case, you'd like to pass some information from the Native app to JavaScript. For example, you might want to pass the user id of the currently logged user to React Native, together with a token that can be used to retrieve information from a database.
522+
523+
This is possible by using the `initialProperties` parameter of the `view(withModuleName:initialProperty)` overload of the `RCTReactNativeFactory` class. The following steps shows you how to do it.
524+
525+
### Update the App.tsx file to read the initial properties.
526+
527+
Open the `App.tsx` file and add the following code:
528+
529+
```diff title="App.tsx"
530+
import {
531+
Colors,
532+
DebugInstructions,
533+
Header,
534+
ReloadInstructions,
535+
} from 'react-native/Libraries/NewAppScreen';
536+
537+
-function App(): React.JSX.Element {
538+
+function App(props): React.JSX.Element {
539+
const isDarkMode = useColorScheme() === 'dark';
540+
541+
const backgroundStyle = {
542+
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
543+
};
544+
545+
return (
546+
<SafeAreaView style={backgroundStyle}>
547+
<StatusBar
548+
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
549+
backgroundColor={backgroundStyle.backgroundColor}
550+
/>
551+
<ScrollView
552+
contentInsetAdjustmentBehavior="automatic"
553+
style={backgroundStyle}>
554+
<Header />
555+
- <View
556+
- style={{
557+
- backgroundColor: isDarkMode
558+
- ? Colors.black
559+
- : Colors.white,
560+
- padding: 24,
561+
- }}>
562+
- <Text style={styles.title}>Step One</Text>
563+
- <Text>
564+
- Edit <Text style={styles.bold}>App.tsx</Text> to
565+
- change this screen and see your edits.
566+
- </Text>
567+
- <Text style={styles.title}>See your changes</Text>
568+
- <ReloadInstructions />
569+
- <Text style={styles.title}>Debug</Text>
570+
- <DebugInstructions />
571+
+ <Text style={styles.title}>UserID: {props.userID}</Text>
572+
+ <Text style={styles.title}>Token: {props.token}</Text>
573+
</View>
574+
</ScrollView>
575+
</SafeAreaView>
576+
);
577+
}
578+
579+
const styles = StyleSheet.create({
580+
title: {
581+
fontSize: 24,
582+
fontWeight: '600',
583+
+ marginLeft: 20,
584+
},
585+
bold: {
586+
fontWeight: '700',
587+
},
588+
});
589+
590+
export default App;
591+
```
592+
593+
These changes will tell React Native that your App component is now accepting some properties. The `RCTreactNativeFactory` will take care of passing them to the component when it's rendered.
594+
595+
### Update the Native code to pass the initial properties to JavaScript.
596+
597+
<Tabs groupId="ios-language" queryString defaultValue={constants.defaultAppleLanguage} values={constants.appleLanguages}>
598+
<TabItem value="objc">
599+
600+
Modify the `ReactViewController.mm` to pass the initial properties to JavaScript.
601+
602+
```diff title="ReactViewController.mm"
603+
- (void)viewDidLoad {
604+
[super viewDidLoad];
605+
// Do any additional setup after loading the view.
606+
607+
_factoryDelegate = [ReactNativeFactoryDelegate new];
608+
_factoryDelegate.dependencyProvider = [RCTAppDependencyProvider new];
609+
_factory = [[RCTReactNativeFactory alloc] initWithDelegate:_factoryDelegate];
610+
- self.view = [_factory.rootViewFactory viewWithModuleName:@"HelloWorld"];
611+
+ self.view = [_factory.rootViewFactory viewWithModuleName:@"HelloWorld" initialProperties:@{
612+
+ @"userID": @"12345678",
613+
+ @"token": @"secretToken"
614+
+ }];
615+
}
616+
```
617+
618+
</TabItem>
619+
<TabItem value="swift">
620+
621+
Modify the `ReactViewController.swift` to pass the initial properties to the React Native view.
622+
623+
```diff title="ReactViewController.swift"
624+
override func viewDidLoad() {
625+
super.viewDidLoad()
626+
reactNativeFactoryDelegate = ReactNativeDelegate()
627+
reactNativeFactoryDelegate!.dependencyProvider = RCTAppDependencyProvider()
628+
reactNativeFactory = RCTReactNativeFactory(delegate: reactNativeFactoryDelegate!)
629+
- view = reactNativeFactory!.rootViewFactory.view(withModuleName: "HelloWorld")
630+
+ view = reactNativeFactory!.rootViewFactory.view(withModuleName: "HelloWorld" initialProperties: [
631+
+ "userID": "12345678",
632+
+ "token": "secretToken"
633+
+])
634+
635+
}
636+
}
637+
```
638+
639+
</TabItem>
640+
</Tabs>
641+
642+
3. Run your app once again. You should see the following screen after you present the `ReactViewController`:
643+
644+
<center>
645+
<img src="/docs/assets/brownfield-with-initial-props.png" width="30%" height="30%"/>
646+
</center>
647+
648+
## Now what?
517649

518650
At this point you can continue developing your app as usual. Refer to our [debugging](debugging) and [deployment](running-on-device) docs to learn more about working with React Native.

docs/_integration-with-existing-apps-kotlin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ class MyReactActivity : ReactActivity() {
424424
</TabItem>
425425
</Tabs>
426426

427-
As usual, here the [MainActivity.kt Community template file as reference](https://github.com/react-native-community/template/blob/0.77-stable/template/android/app/src/main/java/com/helloworld/MainApplication.kt)
427+
As usual, here the [MainActivity.kt Community template file as reference](https://github.com/react-native-community/template/blob/0.80-stable/template/android/app/src/main/java/com/helloworld/MainActivity.kt)
428428

429429
Whenever you create a new Activity, you need to add it to your `AndroidManifest.xml` file. You also need set the theme of `MyReactActivity` to `Theme.AppCompat.Light.NoActionBar` (or to any non-ActionBar theme) as otherwise your application will render an ActionBar on top of your React Native screen:
430430

docs/accessibility.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@ Android and iOS differ slightly in their approaches, and thus the React Native i
1414

1515
### `accessible`
1616

17-
When `true`, indicates that the view is an accessibility element. When a view is an accessibility element, it groups its children into a single selectable component. By default, all touchable elements are accessible.
17+
When `true`, indicates that the view is discoverable by assistive technologies such as screen readers and hardware keyboards. Note that this does not necessarily mean that the view will be focused by VoiceOver or TalkBack. There are a number of reasons for this, such as VoiceOver disallowing nested acecssibility elements, or TalkBack opting to focus some parent element instead.
1818

19-
On Android, `accessible={true}` property for a react-native View will be translated into native `focusable={true}`.
19+
By default, all touchable elements are accessible.
20+
21+
On Android, `accessible` will be translated into native [`focusable`](<https://developer.android.com/reference/android/view/View#setFocusable(boolean)>). On iOS, it translates into native [`isAccessibilityElement`](https://developer.apple.com/documentation/uikit/uiaccessibilityelement/isaccessibilityelement?language=objc).
2022

2123
```tsx
22-
<View accessible={true}>
23-
<Text>text one</Text>
24-
<Text>text two</Text>
24+
<View>
25+
<View accessible={true} />
26+
<View />
2527
</View>
2628
```
2729

28-
In the above example, accessibility focus is only available on the parent view with the `accessible` property, and not individually for 'text one' and 'text two'.
30+
In the above example, accessibility focus is only available on the first child view with the `accessible` property, and not for the parent or sibling without `accessible`.
2931

3032
### `accessibilityLabel`
3133

@@ -427,6 +429,8 @@ When adding support for standard actions, `name` must be one of the following:
427429
- `'increment'` - Increment an adjustable component. On iOS, VoiceOver generates this action when the component has a role of `'adjustable'` and the user places focus on it and swipes upward. On Android, TalkBack generates this action when the user places accessibility focus on the component and presses the volume-up button.
428430
- `'decrement'` - Decrement an adjustable component. On iOS, VoiceOver generates this action when the component has a role of `'adjustable'` and the user places focus on it and swipes downward. On Android, TalkBack generates this action when the user places accessibility focus on the component and presses the volume-down button.
429431
- `'longpress'` - Android only - This action is generated when the user places accessibility focus on the component, then double-taps and holds one finger on the screen. This should perform the same action with, or without, assistive technology.
432+
- `'expand'` - Android only - This action "expands" the component so that TalkBack will announce an "expanded" hint.
433+
- `'collapse'` - Android only - This action "collapses" the component so that TalkBack will announce a "collapsed" hint.
430434

431435
The `label` field is optional for standard actions and is often unused by assistive technologies. For custom actions, it is a localized string containing a description of the action to be presented to the user.
432436

docs/build-speed.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ This can be problematic as your project grows and generally in bigger organizati
88

99
To mitigate this performance hit, this page shares some suggestions on how to **improve your build time**.
1010

11+
:::info
12+
13+
Please note that those suggestions are advanced feature that requires some amount of understanding of how the native build tools work.
14+
15+
:::
16+
1117
## Build only one ABI during development (Android-only)
1218

1319
When building your android app locally, by default you build all the 4 [Application Binary Interfaces (ABIs)](https://developer.android.com/ndk/guides/abis) : `armeabi-v7a`, `arm64-v8a`, `x86` & `x86_64`.
@@ -50,6 +56,31 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
5056

5157
Once you build a **release version** of your app, don't forget to remove those flags as you want to build an apk/app bundle that works for all the ABIs and not only for the one you're using in your daily development workflow.
5258

59+
## Enable Configuration Caching (Android-only)
60+
61+
Since React Native 0.79, you can also enable Gradle Configuration Caching.
62+
63+
When you’re running an Android build with `yarn android`, you will be executing a Gradle build that is composed by two steps ([source](https://docs.gradle.org/current/userguide/build_lifecycle.html)):
64+
65+
- Configuration phase, when all the `.gradle` files are evaluated.
66+
- Execution phase, when the tasks are actually executed so the Java/Kotlin code is compiled and so on.
67+
68+
You will now be able to enable Configuration Caching, which will allow you to skip the Configuration phase on subsequent builds.
69+
70+
This is beneficial when making frequent changes to the native code as it improves build times.
71+
72+
For example here you can see how rebuilding faster it is to rebuild RN-Tester after a change in the native code:
73+
74+
![gradle config caching](/docs/assets/gradle-config-caching.gif)
75+
76+
You can enable Gradle Configuration Caching by adding the following line in your `android/gradle.properties` file:
77+
78+
```
79+
org.gradle.configuration-cache=true
80+
```
81+
82+
Please refer to the [official Gradle documentation](https://docs.gradle.org/current/userguide/configuration_cache.html) for more resources on Configuration Caching.
83+
5384
## Use a compiler cache
5485

5586
If you're running frequent native builds (either C++ or Objective-C), you might benefit from using a **compiler cache**.

docs/fabric-native-components.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,20 @@ Use this specification for our WebView Component:
6060
<TabItem value="typescript">
6161

6262
```typescript title="Demo/specs/WebViewNativeComponent.ts"
63-
import type {HostComponent, ViewProps} from 'react-native';
64-
import type {BubblingEventHandler} from 'react-native/Libraries/Types/CodegenTypes';
65-
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
63+
import type {
64+
CodegenTypes,
65+
HostComponent,
66+
ViewProps,
67+
} from 'react-native';
68+
import {codegenNativeComponent} from 'react-native';
6669

6770
type WebViewScriptLoadedEvent = {
6871
result: 'success' | 'error';
6972
};
7073

7174
export interface NativeProps extends ViewProps {
7275
sourceURL?: string;
73-
onScriptLoaded?: BubblingEventHandler<WebViewScriptLoadedEvent> | null;
76+
onScriptLoaded?: CodegenTypes.BubblingEventHandler<WebViewScriptLoadedEvent> | null;
7477
}
7578

7679
export default codegenNativeComponent<NativeProps>(
@@ -84,9 +87,8 @@ export default codegenNativeComponent<NativeProps>(
8487
```ts title="Demo/RCTWebView/js/RCTWebViewNativeComponent.js":
8588
// @flow strict-local
8689

87-
import type {HostComponent, ViewProps} from 'react-native';
88-
import type {BubblingEventHandler} from 'react-native/Libraries/Types/CodegenTypes';
89-
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
90+
import type {CodegenTypes, HostComponent, ViewProps} from 'react-native';
91+
import {codegenNativeComponent} from 'react-native';
9092

9193
type WebViewScriptLoadedEvent = $ReadOnly<{|
9294
result: "success" | "error",
@@ -95,7 +97,7 @@ type WebViewScriptLoadedEvent = $ReadOnly<{|
9597
type NativeProps = $ReadOnly<{|
9698
...ViewProps,
9799
sourceURL?: string;
98-
onScriptLoaded?: BubblingEventHandler<WebViewScriptLoadedEvent>?;
100+
onScriptLoaded?: CodegenTypes.BubblingEventHandler<WebViewScriptLoadedEvent>?;
99101
|}>;
100102

101103
export default (codegenNativeComponent<NativeProps>(

docs/headless-js-android.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ import com.facebook.react.bridge.Arguments
7676
import com.facebook.react.jstasks.HeadlessJsTaskConfig
7777

7878
class MyTaskService : HeadlessJsTaskService() {
79-
override fun getTaskConfig(intent: Intent): HeadlessJsTaskConfig? {
79+
override fun getTaskConfig(intent: Intent?): HeadlessJsTaskConfig? {
8080
return intent.extras?.let {
8181
HeadlessJsTaskConfig(
8282
"SomeTaskName",

0 commit comments

Comments
 (0)