Skip to content

Commit

Permalink
RCTSafeAreaView (facebook#23006)
Browse files Browse the repository at this point in the history
Summary:
Part of facebook#22990

Changelog:
----------

[iOS] [Changed] - Create individual `RCTSafeAreaViewNativeComponent` JS file from `SafeAreaView` with flow typing.
Pull Request resolved: facebook#23006

Reviewed By: TheSavior

Differential Revision: D13690683

Pulled By: rickhanlonii

fbshipit-source-id: 7928fabf0264a6269a41148432f604e82d9b3920
  • Loading branch information
Illu authored and facebook-github-bot committed Jan 16, 2019
1 parent c669734 commit 40d2097
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
*/

const requireNativeComponent = require('requireNativeComponent');

import type {ViewProps} from 'ViewPropTypes';
import type {NativeComponent} from 'ReactNative';

type NativeProps = $ReadOnly<{|
...ViewProps,
emulateUnlessSupported?: boolean,
|}>;

type RCTSafeAreaViewNativeType = Class<NativeComponent<NativeProps>>;

module.exports = ((requireNativeComponent(
'RCTSafeAreaView',
): any): RCTSafeAreaViewNativeType);
10 changes: 7 additions & 3 deletions Libraries/Components/SafeAreaView/SafeAreaView.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
const Platform = require('Platform');
const React = require('React');
const View = require('View');
const requireNativeComponent = require('requireNativeComponent');

import type {ViewProps} from 'ViewPropTypes';

Expand Down Expand Up @@ -39,10 +38,15 @@ if (Platform.OS === 'android') {
}
};
} else {
const RCTSafeAreaView = requireNativeComponent('RCTSafeAreaView');
const RCTSafeAreaViewNativeComponent = require('RCTSafeAreaViewNativeComponent');
exported = class SafeAreaView extends React.Component<Props> {
render(): React.Node {
return <RCTSafeAreaView emulateUnlessSupported={true} {...this.props} />;
return (
<RCTSafeAreaViewNativeComponent
emulateUnlessSupported={true}
{...this.props}
/>
);
}
};
}
Expand Down

0 comments on commit 40d2097

Please sign in to comment.