Skip to content

Commit 70a1b1a

Browse files
authored
fix: declare support for 0.81 (#2509)
1 parent e8cd9eb commit 70a1b1a

16 files changed

+405
-315
lines changed

example/App.tsx

Lines changed: 0 additions & 280 deletions
This file was deleted.

example/SafeAreaView.tsx

Lines changed: 0 additions & 15 deletions
This file was deleted.

example/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @react-native-webapis
22
import { AppRegistry } from "react-native";
3-
import { App } from "./App";
43
import { name as appName } from "./app.json";
4+
import { App } from "./src/App";
55

66
AppRegistry.registerComponent(appName, () => App);

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"@react-native-community/cli": "^15.0.1",
3434
"@react-native/babel-preset": "^0.78.0",
3535
"@react-native/metro-config": "^0.78.0",
36-
"@rnx-kit/cli": "^0.18.7",
36+
"@rnx-kit/cli": "^0.18.11",
3737
"@rnx-kit/metro-config": "^2.1.0",
3838
"@rnx-kit/polyfills": "^0.2.0",
3939
"@rnx-kit/tsconfig": "^2.0.0",

example/src/App.tsx

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import React, { useCallback, useState } from "react";
2+
import type { NativeSyntheticEvent } from "react-native";
3+
import {
4+
ScrollView,
5+
StatusBar,
6+
Text,
7+
useColorScheme,
8+
View,
9+
} from "react-native";
10+
import { Feature } from "./Feature";
11+
import { LocalStorageStatus } from "./LocalStorage";
12+
import { RemoteDebugging } from "./RemoteDebugging";
13+
import { SafeAreaView } from "./SafeAreaView";
14+
import { Separator } from "./Separator";
15+
import {
16+
getHermesVersion,
17+
isBridgeless,
18+
isConcurrentReactEnabled,
19+
isFabricInstance,
20+
ReactNativeVersion,
21+
} from "./core";
22+
import { useStyles } from "./styles";
23+
24+
declare global {
25+
export const RN$Bridgeless: boolean;
26+
}
27+
28+
type AppProps = {
29+
concurrentRoot?: boolean;
30+
};
31+
32+
function useIsFabricComponent() {
33+
const [isFabric, setIsFabric] = useState(isBridgeless());
34+
const setter = useCallback(
35+
({ currentTarget }: NativeSyntheticEvent<unknown>) => {
36+
setIsFabric(isFabricInstance(currentTarget));
37+
},
38+
[setIsFabric]
39+
);
40+
return [isFabric, setter] as const;
41+
}
42+
43+
export function App(props: AppProps): React.ReactElement<AppProps> {
44+
const isDarkMode = useColorScheme() === "dark";
45+
const styles = useStyles();
46+
const [isFabric, setIsFabric] = useIsFabricComponent();
47+
48+
return (
49+
<SafeAreaView style={styles.body}>
50+
<StatusBar barStyle={isDarkMode ? "light-content" : "dark-content"} />
51+
<ScrollView
52+
contentInsetAdjustmentBehavior="automatic"
53+
onLayout={setIsFabric}
54+
style={styles.body}
55+
>
56+
<Text style={styles.title}>Welcome to React Native</Text>
57+
<RemoteDebugging />
58+
<LocalStorageStatus />
59+
<View style={styles.group}>
60+
<Feature value={ReactNativeVersion.getVersionString()}>
61+
React Native
62+
</Feature>
63+
<Separator />
64+
<Feature value={getHermesVersion() ?? "JSC"}>JS Engine</Feature>
65+
<Separator />
66+
<Feature value={isFabric}>Fabric</Feature>
67+
<Separator />
68+
<Feature value={isConcurrentReactEnabled(props, isFabric)}>
69+
Concurrent React
70+
</Feature>
71+
<Separator />
72+
<Feature value={isBridgeless()}>Bridgeless</Feature>
73+
</View>
74+
</ScrollView>
75+
</SafeAreaView>
76+
);
77+
}

0 commit comments

Comments
 (0)