From f4fd248d53125b25a780fce6ca654a53eb4fd908 Mon Sep 17 00:00:00 2001 From: Alan Lee Date: Mon, 9 Sep 2024 19:43:27 -0700 Subject: [PATCH] fix SafeAreaView mis-used import (#46402) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46402 JS code for importing SafeAreaView is causing error in windows due to import being used. Fix it by using conditional require instead Changelog: [Internal] - Fixed mis-used import of core only SafeAreaView in JS Reviewed By: fkgozali Differential Revision: D62392588 fbshipit-source-id: 65c4728ff73b43cc54543ec2d141a88fce1275ca --- .../SafeAreaView_INTERNAL_DO_NOT_USE.js | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/react-native/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js b/packages/react-native/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js index ae4aeb0bc18..3cf238fa81c 100644 --- a/packages/react-native/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js +++ b/packages/react-native/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js @@ -13,15 +13,17 @@ import type {ViewProps} from '../../../Libraries/Components/View/ViewPropTypes'; import Platform from '../../../Libraries/Utilities/Platform'; import View from '../../../Libraries/Components/View/View'; import * as React from 'react'; -export * from '../../../src/private/specs/components/RCTSafeAreaViewNativeComponent'; -import RCTSafeAreaViewNativeComponent from '../../../src/private/specs/components/RCTSafeAreaViewNativeComponent'; -let exported: React.AbstractComponent>; - -if (Platform.OS === 'android' || Platform.OS === 'ios') { - exported = RCTSafeAreaViewNativeComponent; -} else { - exported = View; -} +const exported: React.AbstractComponent< + ViewProps, + React.ElementRef, +> = Platform.select({ + ios: require('../../../src/private/specs/components/RCTSafeAreaViewNativeComponent') + .default, + android: + require('../../../src/private/specs/components/RCTSafeAreaViewNativeComponent') + .default, + default: View, +}); export default exported;