Skip to content

Commit d5045f2

Browse files
committed
fix: declare support for 0.81
1 parent a04e6da commit d5045f2

File tree

5 files changed

+52
-25
lines changed

5 files changed

+52
-25
lines changed

example/App.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import {
1010
useColorScheme,
1111
View,
1212
} from "react-native";
13-
// @ts-expect-error no type definitions available
14-
import { version as coreVersion } from "react-native/Libraries/Core/ReactNativeVersion";
1513
import { SafeAreaView } from "./SafeAreaView";
1614

1715
declare global {
@@ -31,6 +29,14 @@ type FeatureProps =
3129
onValueChange?: (value: boolean) => void;
3230
};
3331

32+
type ReactNativeVersion = {
33+
major: number;
34+
minor: number;
35+
patch: number;
36+
prerelease?: string;
37+
getVersionString?: () => string;
38+
};
39+
3440
// https://github.com/facebook/react-native/blob/0abd5d63e1c0c4708f81bd698e6d011fa75f01e5/packages/new-app-screen/src/Theme.js#L16-L33
3541
const COLORS = {
3642
light: {
@@ -51,6 +57,17 @@ const COLORS = {
5157
},
5258
};
5359

60+
const ReactNativeVersion: ReactNativeVersion = (() => {
61+
// https://github.com/facebook/react-native/commit/ec5638abd0e872be62b6ea5d8df9bed6335c2191
62+
const { ReactNativeVersion } = require("react-native");
63+
if (ReactNativeVersion) {
64+
return ReactNativeVersion;
65+
}
66+
67+
const { version } = require("react-native/Libraries/Core/ReactNativeVersion");
68+
return version;
69+
})();
70+
5471
function getHermesVersion(): string | undefined {
5572
const version =
5673
"HermesInternal" in global &&
@@ -66,7 +83,11 @@ function getHermesVersion(): string | undefined {
6683
}
6784

6885
function getReactNativeVersion(): string {
69-
const { major, minor, patch, prerelease } = coreVersion;
86+
if (ReactNativeVersion.getVersionString) {
87+
return ReactNativeVersion.getVersionString();
88+
}
89+
90+
const { major, minor, patch, prerelease } = ReactNativeVersion;
7091
const version = `${major}.${minor}.${patch}`;
7192
return prerelease ? `${version}-${prerelease.replace("-", "\n")}` : version;
7293
}
@@ -76,7 +97,7 @@ function isBridgeless() {
7697
}
7798

7899
function isConcurrentReactEnabled(props: AppProps, isFabric: boolean): boolean {
79-
const { major, minor } = coreVersion;
100+
const { major, minor } = ReactNativeVersion;
80101
const version = major * 10000 + minor;
81102
// As of 0.74, it won't be possible to opt-out:
82103
// https://github.com/facebook/react-native/commit/30d186c3683228d4fb7a42f804eb2fdfa7c8ac03

example/SafeAreaView.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as React from "react";
2+
import { View } from "react-native";
23
import type { SafeAreaViewProps } from "react-native-safe-area-context";
34
import {
45
SafeAreaProvider,
@@ -7,9 +8,14 @@ import {
78
} from "react-native-safe-area-context";
89

910
export function SafeAreaView(props: SafeAreaViewProps) {
10-
return (
11-
<SafeAreaProvider initialMetrics={initialWindowMetrics}>
12-
<SafeAreaViewInternal {...props} />
13-
</SafeAreaProvider>
14-
);
11+
// TODO: `SafeAreaView` currently crashes in bridgeless mode
12+
if ("RN$Bridgeless" in global && RN$Bridgeless === true) {
13+
return <View {...props} />;
14+
} else {
15+
return (
16+
<SafeAreaProvider initialMetrics={initialWindowMetrics}>
17+
<SafeAreaViewInternal {...props} />
18+
</SafeAreaProvider>
19+
);
20+
}
1521
}

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",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
"@callstack/react-native-visionos": "0.73 - 0.78",
102102
"@expo/config-plugins": ">=5.0",
103103
"react": "18.1 - 19.1",
104-
"react-native": "0.70 - 0.80 || >=0.81.0-0 <0.81.0",
104+
"react-native": "0.70 - 0.81 || >=0.82.0-0 <0.82.0",
105105
"react-native-macos": "^0.0.0-0 || 0.71 - 0.78",
106106
"react-native-windows": "^0.0.0-0 || 0.70 - 0.79"
107107
},

yarn.lock

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3661,9 +3661,9 @@ __metadata:
36613661
languageName: node
36623662
linkType: hard
36633663

3664-
"@rnx-kit/cli@npm:^0.18.7":
3665-
version: 0.18.10
3666-
resolution: "@rnx-kit/cli@npm:0.18.10"
3664+
"@rnx-kit/cli@npm:^0.18.11":
3665+
version: 0.18.11
3666+
resolution: "@rnx-kit/cli@npm:0.18.11"
36673667
dependencies:
36683668
"@rnx-kit/align-deps": "npm:^3.1.0"
36693669
"@rnx-kit/config": "npm:^0.7.0"
@@ -3675,7 +3675,7 @@ __metadata:
36753675
"@rnx-kit/metro-serializer-esbuild": "npm:^0.2.1"
36763676
"@rnx-kit/metro-service": "npm:^4.0.2"
36773677
"@rnx-kit/third-party-notices": "npm:^2.0.0"
3678-
"@rnx-kit/tools-android": "npm:^0.2.0"
3678+
"@rnx-kit/tools-android": "npm:^0.2.1"
36793679
"@rnx-kit/tools-apple": "npm:^0.2.1"
36803680
"@rnx-kit/tools-filesystem": "npm:^0.1.0"
36813681
"@rnx-kit/tools-language": "npm:^3.0.0"
@@ -3694,7 +3694,7 @@ __metadata:
36943694
optional: true
36953695
bin:
36963696
rnx-cli: bin/rnx-cli.cjs
3697-
checksum: 10c0/b568d645374b7718966a9c9f11ca318de7bdbf1e2310397f163ddf93e3d9a457f9e3b63fc242ce9631de3ea925d830115720424ccc99a31ff5ed500ec8f8b3b2
3697+
checksum: 10c0/6d2fb5ab342290180cf74327e3e456b842e0b8213f14c98b85e6744deeb4872a304e028ee37fe95cf20a71adcd67e6ab4df5191cec7ea917edbff111fdc28966
36983698
languageName: node
36993699
linkType: hard
37003700

@@ -3888,12 +3888,12 @@ __metadata:
38883888
languageName: node
38893889
linkType: hard
38903890

3891-
"@rnx-kit/tools-android@npm:^0.2.0":
3892-
version: 0.2.0
3893-
resolution: "@rnx-kit/tools-android@npm:0.2.0"
3891+
"@rnx-kit/tools-android@npm:^0.2.1":
3892+
version: 0.2.1
3893+
resolution: "@rnx-kit/tools-android@npm:0.2.1"
38943894
dependencies:
38953895
"@rnx-kit/tools-shell": "npm:^0.2.0"
3896-
checksum: 10c0/112844ba10b8efdd6ba05d5a626aca1a0f319112a1ec54cdedf9d2c1c51ac424fe728575a6f457a2dbb5a1174b5e47d32a1afbd7feb08f05814ff1dc12c40f60
3896+
checksum: 10c0/63ec0ffb0325b3dd541b80052ad17401084132daa7812613057e445c0431741447046ea6356d237530167ce6383d51dfe56b82b5672aa83ce3523c027a941fcf
38973897
languageName: node
38983898
linkType: hard
38993899

@@ -3939,11 +3939,11 @@ __metadata:
39393939
linkType: hard
39403940

39413941
"@rnx-kit/tools-react-native@npm:^2.0.0, @rnx-kit/tools-react-native@npm:^2.0.3, @rnx-kit/tools-react-native@npm:^2.1.0":
3942-
version: 2.1.0
3943-
resolution: "@rnx-kit/tools-react-native@npm:2.1.0"
3942+
version: 2.2.0
3943+
resolution: "@rnx-kit/tools-react-native@npm:2.2.0"
39443944
dependencies:
39453945
"@rnx-kit/tools-node": "npm:^3.0.0"
3946-
checksum: 10c0/ac7bcaaf870463fe51cbd3f2aac631c41c085e00dd1809706ad33f498f1feba31cde611662d5ec55bd25b48ac367c8e5c4eead8749b6e6989b380b4cb6b9a161
3946+
checksum: 10c0/631eecefda6b2b53eccdd18656f24a5426625522b80e956504d2b37acbcdc1e98eddc692aec0833536e6fd1b285c4a5d75e27f23a16fdcb099fabae46013740d
39473947
languageName: node
39483948
linkType: hard
39493949

@@ -7766,7 +7766,7 @@ __metadata:
77667766
"@react-native-webapis/web-storage": "npm:^0.4.1"
77677767
"@react-native/babel-preset": "npm:^0.78.0"
77687768
"@react-native/metro-config": "npm:^0.78.0"
7769-
"@rnx-kit/cli": "npm:^0.18.7"
7769+
"@rnx-kit/cli": "npm:^0.18.11"
77707770
"@rnx-kit/metro-config": "npm:^2.1.0"
77717771
"@rnx-kit/polyfills": "npm:^0.2.0"
77727772
"@rnx-kit/tsconfig": "npm:^2.0.0"
@@ -12228,7 +12228,7 @@ __metadata:
1222812228
"@callstack/react-native-visionos": 0.73 - 0.78
1222912229
"@expo/config-plugins": ">=5.0"
1223012230
react: 18.1 - 19.1
12231-
react-native: 0.70 - 0.80 || >=0.81.0-0 <0.81.0
12231+
react-native: 0.70 - 0.81 || >=0.82.0-0 <0.82.0
1223212232
react-native-macos: ^0.0.0-0 || 0.71 - 0.78
1223312233
react-native-windows: ^0.0.0-0 || 0.70 - 0.79
1223412234
peerDependenciesMeta:

0 commit comments

Comments
 (0)