diff --git a/packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js b/packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js index e3da1d7798c..290fdbd0e06 100644 --- a/packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js +++ b/packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js @@ -24,7 +24,7 @@ import * as React from 'react'; * sensor housing area on iPhone X). */ const exported: component( - ref: React.RefSetter>, + ref?: React.RefSetter>, ...props: ViewProps ) = Platform.select({ ios: require('./RCTSafeAreaViewNativeComponent').default, diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index e5618a6d226..80e4db785a3 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -1795,7 +1795,7 @@ declare export default typeof RCTSafeAreaViewNativeComponent; exports[`public API should not change unintentionally Libraries/Components/SafeAreaView/SafeAreaView.js 1`] = ` "declare const exported: component( - ref: React.RefSetter>, + ref?: React.RefSetter>, ...props: ViewProps ); declare export default typeof exported; diff --git a/packages/react-native/types/__typetests__/index.tsx b/packages/react-native/types/__typetests__/index.tsx index ed2260f83db..dcec36186ad 100644 --- a/packages/react-native/types/__typetests__/index.tsx +++ b/packages/react-native/types/__typetests__/index.tsx @@ -110,6 +110,7 @@ import { UIManager, View, ViewStyle, + SafeAreaView, VirtualizedList, findNodeHandle, requireNativeComponent, @@ -1568,6 +1569,31 @@ class BridgedComponentTest extends React.Component { } } +const SafeAreaViewTest = () => { + const viewRef = React.createRef>(); + + return ( + <> + ; + ; + { + ref?.focus(); + ref?.blur(); + ref?.measure( + (x, y, width, height, pageX, pageY): number => + x + y + width + height + pageX + pageY, + ); + ref?.measureInWindow( + (x, y, width, height): number => x + y + width + height, + ); + ref?.setNativeProps({focusable: false}); + }} + /> + + ); +}; + const SwitchRefTest = () => { const switchRef = React.createRef>(); diff --git a/scripts/build/build-types/buildTypes.js b/scripts/build/build-types/buildTypes.js index 43ec47c53f7..9d571e4d9db 100644 --- a/scripts/build/build-types/buildTypes.js +++ b/scripts/build/build-types/buildTypes.js @@ -82,6 +82,7 @@ const ENTRY_POINTS = [ 'packages/react-native/Libraries/Components/RefreshControl/RefreshControl.js', 'packages/react-native/Libraries/Image/Image.js.flow', 'packages/react-native/Libraries/Image/ImageBackground.js', + 'packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js', ]; /**