diff --git a/Libraries/Components/SafeAreaView/SafeAreaView.js b/Libraries/Components/SafeAreaView/SafeAreaView.js index 9c22f7dabb1..22fc9e44553 100644 --- a/Libraries/Components/SafeAreaView/SafeAreaView.js +++ b/Libraries/Components/SafeAreaView/SafeAreaView.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ @@ -12,6 +12,7 @@ const Platform = require('../../Utilities/Platform'); const React = require('react'); const View = require('../View/View'); +import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; import type {ViewProps} from '../View/ViewPropTypes'; type Props = $ReadOnly<{| @@ -19,7 +20,10 @@ type Props = $ReadOnly<{| emulateUnlessSupported?: boolean, |}>; -let exported: Class>; +let exported: React.AbstractComponent< + Props, + React.ElementRef>, +>; /** * Renders nested content and automatically applies paddings reflect the portion @@ -31,37 +35,27 @@ let exported: Class>; * sensor housing area on iPhone X). */ if (Platform.OS === 'android') { - const SafeAreaView = ( - props: Props, - forwardedRef?: ?React.Ref, - ) => { - const {emulateUnlessSupported, ...localProps} = props; - return ; - }; - - const SafeAreaViewRef = React.forwardRef(SafeAreaView); - SafeAreaViewRef.displayName = 'SafeAreaView'; - exported = ((SafeAreaViewRef: any): Class>); + exported = React.forwardRef>>( + function SafeAreaView(props, forwardedRef) { + const {emulateUnlessSupported, ...localProps} = props; + return ; + }, + ); } else { const RCTSafeAreaViewNativeComponent = require('./RCTSafeAreaViewNativeComponent') .default; - const SafeAreaView = ( - props: Props, - forwardedRef?: ?React.Ref, - ) => { - return ( - - ); - }; - - const SafeAreaViewRef = React.forwardRef(SafeAreaView); - SafeAreaViewRef.displayName = 'SafeAreaView'; - exported = ((SafeAreaViewRef: any): Class>); + exported = React.forwardRef>>( + function SafeAreaView(props, forwardedRef) { + return ( + + ); + }, + ); } module.exports = exported; diff --git a/Libraries/Components/SafeAreaView/__tests__/__snapshots__/SafeAreaView-test.js.snap b/Libraries/Components/SafeAreaView/__tests__/__snapshots__/SafeAreaView-test.js.snap index 93c8ecf54c9..9f41a3b95b4 100644 --- a/Libraries/Components/SafeAreaView/__tests__/__snapshots__/SafeAreaView-test.js.snap +++ b/Libraries/Components/SafeAreaView/__tests__/__snapshots__/SafeAreaView-test.js.snap @@ -25,21 +25,21 @@ exports[` should render as when not mocked 1`] = `; exports[` should shallow render as when mocked 1`] = ` - + Hello World! - + `; exports[` should shallow render as when not mocked 1`] = ` - + Hello World! - + `;