Skip to content

Commit

Permalink
Add SafeAreaView to buildTypes and align Flow with TS types (#49664)
Browse files Browse the repository at this point in the history
Summary:

Changelog:
[Internal] - Added SafeAreaView to buildTypes and aligned Flow with TS types

Reviewed By: huntie

Differential Revision: D70176107
  • Loading branch information
coado authored and facebook-github-bot committed Feb 26, 2025
1 parent ac57ec4 commit c4350e0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import * as React from 'react';
* sensor housing area on iPhone X).
*/
const exported: component(
ref: React.RefSetter<React.ElementRef<typeof View>>,
ref?: React.RefSetter<React.ElementRef<typeof View>>,
...props: ViewProps
) = Platform.select({
ios: require('./RCTSafeAreaViewNativeComponent').default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<React.ElementRef<typeof View>>,
ref?: React.RefSetter<React.ElementRef<typeof View>>,
...props: ViewProps
);
declare export default typeof exported;
Expand Down
26 changes: 26 additions & 0 deletions packages/react-native/types/__typetests__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ import {
UIManager,
View,
ViewStyle,
SafeAreaView,
VirtualizedList,
findNodeHandle,
requireNativeComponent,
Expand Down Expand Up @@ -1568,6 +1569,31 @@ class BridgedComponentTest extends React.Component {
}
}

const SafeAreaViewTest = () => {
const viewRef = React.createRef<React.ElementRef<typeof View>>();

return (
<>
<SafeAreaView />;
<SafeAreaView ref={viewRef} />;
<SafeAreaView
ref={ref => {
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<React.ElementRef<typeof Switch>>();

Expand Down
1 change: 1 addition & 0 deletions scripts/build/build-types/buildTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
];

/**
Expand Down

0 comments on commit c4350e0

Please sign in to comment.