Skip to content

Commit b2699c6

Browse files
authored
chore: replace deprecated SafeAreaView (#2504)
1 parent 6229cc2 commit b2699c6

File tree

7 files changed

+46
-1
lines changed

7 files changed

+46
-1
lines changed

example/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { useCallback, useEffect, useMemo, useState } from "react";
22
import type { NativeSyntheticEvent } from "react-native";
33
import {
44
NativeModules,
5-
SafeAreaView,
65
ScrollView,
76
StatusBar,
87
StyleSheet,
@@ -13,6 +12,7 @@ import {
1312
} from "react-native";
1413
// @ts-expect-error no type definitions available
1514
import { version as coreVersion } from "react-native/Libraries/Core/ReactNativeVersion";
15+
import { SafeAreaView } from "./SafeAreaView";
1616

1717
declare global {
1818
export const RN$Bridgeless: boolean;

example/SafeAreaView.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import * as React from "react";
2+
import type { SafeAreaViewProps } from "react-native-safe-area-context";
3+
import {
4+
SafeAreaProvider,
5+
SafeAreaView as SafeAreaViewInternal,
6+
initialWindowMetrics,
7+
} from "react-native-safe-area-context";
8+
9+
export function SafeAreaView(props: SafeAreaViewProps) {
10+
return (
11+
<SafeAreaProvider initialMetrics={initialWindowMetrics}>
12+
<SafeAreaViewInternal {...props} />
13+
</SafeAreaProvider>
14+
);
15+
}

example/ios/Podfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,8 @@ PODS:
12111211
- React-jsiexecutor
12121212
- React-RCTFBReactNativeSpec
12131213
- ReactCommon/turbomodule/core
1214+
- react-native-safe-area-context (5.5.2):
1215+
- React-Core
12141216
- React-NativeModulesApple (0.78.2):
12151217
- glog
12161218
- React-callinvoker
@@ -1572,6 +1574,7 @@ DEPENDENCIES:
15721574
- React-logger (from `../../node_modules/react-native/ReactCommon/logger`)
15731575
- React-Mapbuffer (from `../../node_modules/react-native/ReactCommon`)
15741576
- React-microtasksnativemodule (from `../../node_modules/react-native/ReactCommon/react/nativemodule/microtasks`)
1577+
- react-native-safe-area-context (from `../../node_modules/react-native-safe-area-context`)
15751578
- React-NativeModulesApple (from `../../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
15761579
- React-perflogger (from `../../node_modules/react-native/ReactCommon/reactperflogger`)
15771580
- React-performancetimeline (from `../../node_modules/react-native/ReactCommon/react/performance/timeline`)
@@ -1684,6 +1687,8 @@ EXTERNAL SOURCES:
16841687
:path: "../../node_modules/react-native/ReactCommon"
16851688
React-microtasksnativemodule:
16861689
:path: "../../node_modules/react-native/ReactCommon/react/nativemodule/microtasks"
1690+
react-native-safe-area-context:
1691+
:path: "../../node_modules/react-native-safe-area-context"
16871692
React-NativeModulesApple:
16881693
:path: "../../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios"
16891694
React-perflogger:
@@ -1787,6 +1792,7 @@ SPEC CHECKSUMS:
17871792
React-logger: 763728cf4eebc9c5dc9bfc3649e22295784f69f3
17881793
React-Mapbuffer: 63278529b5cf531a7eaf8fc71244fabb062ca90c
17891794
React-microtasksnativemodule: 8eac9377da54b41703abb23e3781b9c413acfdc8
1795+
react-native-safe-area-context: 0f7bf11598f9a61b7ceac8dc3f59ef98697e99e1
17901796
React-NativeModulesApple: 83ea61c133a66d967bbd8abbb5bf3c2cdcd5ff25
17911797
React-perflogger: 5f8fa36a8e168fb355efe72099efe77213bc2ac6
17921798
React-performancetimeline: 8c0ecfa1ae459cc5678a65f95ac3bf85644d6feb

example/macos/Podfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,8 @@ PODS:
12121212
- React-jsiexecutor
12131213
- React-RCTFBReactNativeSpec
12141214
- ReactCommon/turbomodule/core
1215+
- react-native-safe-area-context (5.5.2):
1216+
- React-Core
12151217
- React-NativeModulesApple (0.78.3):
12161218
- glog
12171219
- React-callinvoker
@@ -1573,6 +1575,7 @@ DEPENDENCIES:
15731575
- React-logger (from `../../node_modules/react-native-macos/ReactCommon/logger`)
15741576
- React-Mapbuffer (from `../../node_modules/react-native-macos/ReactCommon`)
15751577
- React-microtasksnativemodule (from `../../node_modules/react-native-macos/ReactCommon/react/nativemodule/microtasks`)
1578+
- react-native-safe-area-context (from `../../node_modules/react-native-safe-area-context`)
15761579
- React-NativeModulesApple (from `../../node_modules/react-native-macos/ReactCommon/react/nativemodule/core/platform/ios`)
15771580
- React-perflogger (from `../../node_modules/react-native-macos/ReactCommon/reactperflogger`)
15781581
- React-performancetimeline (from `../../node_modules/react-native-macos/ReactCommon/react/performance/timeline`)
@@ -1682,6 +1685,8 @@ EXTERNAL SOURCES:
16821685
:path: "../../node_modules/react-native-macos/ReactCommon"
16831686
React-microtasksnativemodule:
16841687
:path: "../../node_modules/react-native-macos/ReactCommon/react/nativemodule/microtasks"
1688+
react-native-safe-area-context:
1689+
:path: "../../node_modules/react-native-safe-area-context"
16851690
React-NativeModulesApple:
16861691
:path: "../../node_modules/react-native-macos/ReactCommon/react/nativemodule/core/platform/ios"
16871692
React-perflogger:
@@ -1787,6 +1792,7 @@ SPEC CHECKSUMS:
17871792
React-logger: 403502d548fbc097ab2c5a783ca98f5e84390bad
17881793
React-Mapbuffer: 3815edc6553967769cdd5e9127284926416270f0
17891794
React-microtasksnativemodule: 67e75d6d737a78daaee8ea4300ddb555ef0909b0
1795+
react-native-safe-area-context: 0f7bf11598f9a61b7ceac8dc3f59ef98697e99e1
17901796
React-NativeModulesApple: b575fb27ea57ed5be05928d26ebae10ec2784a43
17911797
React-perflogger: 3756bfe3ff8cc8fffed3c51dce34cef861d4b82a
17921798
React-performancetimeline: c4678b2226a660268cc478662ffc43a2ab1b5d30

example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"react": "19.0.0",
2525
"react-native": "^0.78.0",
2626
"react-native-macos": "^0.78.0",
27+
"react-native-safe-area-context": "^5.5.2",
2728
"react-native-windows": "^0.78.0"
2829
},
2930
"devDependencies": {

example/visionos/Podfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,8 @@ PODS:
12451245
- React-jsiexecutor
12461246
- React-RCTFBReactNativeSpec
12471247
- ReactCommon/turbomodule/core
1248+
- react-native-safe-area-context (5.5.2):
1249+
- React-Core
12481250
- React-NativeModulesApple (0.78.0):
12491251
- glog
12501252
- React-callinvoker
@@ -1626,6 +1628,7 @@ DEPENDENCIES:
16261628
- "React-logger (from `../node_modules/@callstack/react-native-visionos/ReactCommon/logger`)"
16271629
- "React-Mapbuffer (from `../node_modules/@callstack/react-native-visionos/ReactCommon`)"
16281630
- "React-microtasksnativemodule (from `../node_modules/@callstack/react-native-visionos/ReactCommon/react/nativemodule/microtasks`)"
1631+
- react-native-safe-area-context (from `../../node_modules/react-native-safe-area-context`)
16291632
- "React-NativeModulesApple (from `../node_modules/@callstack/react-native-visionos/ReactCommon/react/nativemodule/core/platform/ios`)"
16301633
- "React-perflogger (from `../node_modules/@callstack/react-native-visionos/ReactCommon/reactperflogger`)"
16311634
- "React-performancetimeline (from `../node_modules/@callstack/react-native-visionos/ReactCommon/react/performance/timeline`)"
@@ -1741,6 +1744,8 @@ EXTERNAL SOURCES:
17411744
:path: "../node_modules/@callstack/react-native-visionos/ReactCommon"
17421745
React-microtasksnativemodule:
17431746
:path: "../node_modules/@callstack/react-native-visionos/ReactCommon/react/nativemodule/microtasks"
1747+
react-native-safe-area-context:
1748+
:path: "../../node_modules/react-native-safe-area-context"
17441749
React-NativeModulesApple:
17451750
:path: "../node_modules/@callstack/react-native-visionos/ReactCommon/react/nativemodule/core/platform/ios"
17461751
React-perflogger:
@@ -1850,6 +1855,7 @@ SPEC CHECKSUMS:
18501855
React-logger: 9861e645fb221ca8c40a65fe19f7a0c968d6a324
18511856
React-Mapbuffer: 4eebc9c2565dc0cd2453e70525cf591650345bfb
18521857
React-microtasksnativemodule: c750a8a62a0b84afcab68e67f4e7fc6f594d34f4
1858+
react-native-safe-area-context: 0f7bf11598f9a61b7ceac8dc3f59ef98697e99e1
18531859
React-NativeModulesApple: 302a72119df5cd41283fe789072eda34ec51317a
18541860
React-perflogger: f7cf057acfecf79822c1ca760fc558c3401635e0
18551861
React-performancetimeline: f155e5e07c033691618adc82429532119751cf2f

yarn.lock

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7769,6 +7769,7 @@ __metadata:
77697769
react: "npm:19.0.0"
77707770
react-native: "npm:^0.78.0"
77717771
react-native-macos: "npm:^0.78.0"
7772+
react-native-safe-area-context: "npm:^5.5.2"
77727773
react-native-test-app: "workspace:*"
77737774
react-native-windows: "npm:^0.78.0"
77747775
webdriverio: "npm:^9.0.0"
@@ -12162,6 +12163,16 @@ __metadata:
1216212163
languageName: node
1216312164
linkType: hard
1216412165

12166+
"react-native-safe-area-context@npm:^5.5.2":
12167+
version: 5.5.2
12168+
resolution: "react-native-safe-area-context@npm:5.5.2"
12169+
peerDependencies:
12170+
react: "*"
12171+
react-native: "*"
12172+
checksum: 10c0/529cafcafbc1d994f6d9c9be41ae4f78768b7c103a22265d3fe5223a930249e0a07a934b5ec358ce510622061f339a20c2147b620bd15032366b12b4258c2ce5
12173+
languageName: node
12174+
linkType: hard
12175+
1216512176
"react-native-test-app@workspace:*, react-native-test-app@workspace:.":
1216612177
version: 0.0.0-use.local
1216712178
resolution: "react-native-test-app@workspace:."

0 commit comments

Comments
 (0)