Skip to content

Commit

Permalink
fix SafeAreaView mis-used import (#46402)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #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
  • Loading branch information
alanleedev authored and cipolleschi committed Sep 16, 2024
1 parent c41ab47 commit f4fd248
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ViewProps, React.ElementRef<typeof View>>;

if (Platform.OS === 'android' || Platform.OS === 'ios') {
exported = RCTSafeAreaViewNativeComponent;
} else {
exported = View;
}
const exported: React.AbstractComponent<
ViewProps,
React.ElementRef<typeof View>,
> = Platform.select({
ios: require('../../../src/private/specs/components/RCTSafeAreaViewNativeComponent')
.default,
android:
require('../../../src/private/specs/components/RCTSafeAreaViewNativeComponent')
.default,
default: View,
});

export default exported;

0 comments on commit f4fd248

Please sign in to comment.