Skip to content

Commit 3088140

Browse files
coadogabrieldonadel
authored andcommitted
Set optional ref on View and split View Props (facebook#49725)
Summary: Pull Request resolved: facebook#49725 Changelog: [Internal] - Set optional ref on View and split View Props Reviewed By: huntie Differential Revision: D70327820 fbshipit-source-id: 2021125b0aff1497df50c2be73c2ecfc7e8f1157
1 parent f33e0f7 commit 3088140

File tree

3 files changed

+29
-23
lines changed

3 files changed

+29
-23
lines changed

packages/react-native/Libraries/Components/View/View.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export type Props = ViewProps;
2424
* @see https://reactnative.dev/docs/view
2525
*/
2626
const View: component(
27-
ref: React.RefSetter<React.ElementRef<typeof ViewNativeComponent>>,
27+
ref?: React.RefSetter<React.ElementRef<typeof ViewNativeComponent>>,
2828
...props: ViewProps
2929
) = React.forwardRef(
3030
(

packages/react-native/Libraries/Components/View/ViewPropTypes.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -356,17 +356,7 @@ export type ViewPropsIOS = $ReadOnly<{
356356
shouldRasterizeIOS?: ?boolean,
357357
}>;
358358

359-
export type ViewProps = $ReadOnly<{
360-
...DirectEventProps,
361-
...GestureResponderHandlers,
362-
...MouseEventProps,
363-
...PointerEventProps,
364-
...FocusEventProps,
365-
...TouchEventProps,
366-
...ViewPropsAndroid,
367-
...ViewPropsIOS,
368-
...AccessibilityProps,
369-
359+
type ViewBaseProps = $ReadOnly<{
370360
children?: Node,
371361
style?: ?ViewStyleProp,
372362

@@ -454,3 +444,16 @@ export type ViewProps = $ReadOnly<{
454444
*/
455445
removeClippedSubviews?: ?boolean,
456446
}>;
447+
448+
export type ViewProps = $ReadOnly<{
449+
...DirectEventProps,
450+
...GestureResponderHandlers,
451+
...MouseEventProps,
452+
...PointerEventProps,
453+
...FocusEventProps,
454+
...TouchEventProps,
455+
...ViewPropsAndroid,
456+
...ViewPropsIOS,
457+
...AccessibilityProps,
458+
...ViewBaseProps,
459+
}>;

packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3633,7 +3633,7 @@ declare export default typeof ReactNativeViewAttributes;
36333633
exports[`public API should not change unintentionally Libraries/Components/View/View.js 1`] = `
36343634
"export type Props = ViewProps;
36353635
declare const View: component(
3636-
ref: React.RefSetter<React.ElementRef<typeof ViewNativeComponent>>,
3636+
ref?: React.RefSetter<React.ElementRef<typeof ViewNativeComponent>>,
36373637
...props: ViewProps
36383638
);
36393639
declare export default typeof View;
@@ -3927,16 +3927,7 @@ export type ViewPropsAndroid = $ReadOnly<{
39273927
export type ViewPropsIOS = $ReadOnly<{
39283928
shouldRasterizeIOS?: ?boolean,
39293929
}>;
3930-
export type ViewProps = $ReadOnly<{
3931-
...DirectEventProps,
3932-
...GestureResponderHandlers,
3933-
...MouseEventProps,
3934-
...PointerEventProps,
3935-
...FocusEventProps,
3936-
...TouchEventProps,
3937-
...ViewPropsAndroid,
3938-
...ViewPropsIOS,
3939-
...AccessibilityProps,
3930+
type ViewBaseProps = $ReadOnly<{
39403931
children?: Node,
39413932
style?: ?ViewStyleProp,
39423933
collapsable?: ?boolean,
@@ -3949,6 +3940,18 @@ export type ViewProps = $ReadOnly<{
39493940
pointerEvents?: ?(\\"auto\\" | \\"box-none\\" | \\"box-only\\" | \\"none\\"),
39503941
removeClippedSubviews?: ?boolean,
39513942
}>;
3943+
export type ViewProps = $ReadOnly<{
3944+
...DirectEventProps,
3945+
...GestureResponderHandlers,
3946+
...MouseEventProps,
3947+
...PointerEventProps,
3948+
...FocusEventProps,
3949+
...TouchEventProps,
3950+
...ViewPropsAndroid,
3951+
...ViewPropsIOS,
3952+
...AccessibilityProps,
3953+
...ViewBaseProps,
3954+
}>;
39523955
"
39533956
`;
39543957

0 commit comments

Comments
 (0)