Skip to content

Commit dadd7cd

Browse files
SamChou19815facebook-github-bot
authored andcommitted
Make ref prop optional in xplat: 1/n (#53801)
Summary: Pull Request resolved: #53801 Changelog: [Internal] Reviewed By: panagosg7 Differential Revision: D82507711 fbshipit-source-id: 27c8004c0475765705a01c0b6afb274dab443a38
1 parent 4308185 commit dadd7cd

File tree

8 files changed

+88
-88
lines changed

8 files changed

+88
-88
lines changed

packages/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ interface Instance extends React.ElementRef<typeof Animated.View> {
4444
}
4545

4646
const ScrollViewStickyHeader: component(
47-
ref: React.RefSetter<Instance>,
47+
ref?: React.RefSetter<Instance>,
4848
...props: ScrollViewStickyHeaderProps
4949
) = function ScrollViewStickyHeader({
5050
ref: forwardedRef,
@@ -282,7 +282,7 @@ const ScrollViewStickyHeader: component(
282282
const passthroughAnimatedPropExplicitValues =
283283
isFabric && translateY != null
284284
? {
285-
style: {transform: [{translateY: translateY}]},
285+
style: {transform: [{translateY}]},
286286
}
287287
: null;
288288

@@ -303,20 +303,20 @@ const ScrollViewStickyHeader: component(
303303
passthroughAnimatedPropExplicitValues
304304
}>
305305
{cloneElement(child, {
306-
style: styles.fill, // We transfer the child style to the wrapper.
307306
onLayout: undefined, // we call this manually through our this._onLayout
307+
style: styles.fill, // We transfer the child style to the wrapper.
308308
})}
309309
</Animated.View>
310310
);
311311
};
312312

313313
const styles = StyleSheet.create({
314-
header: {
315-
zIndex: 10,
316-
},
317314
fill: {
318315
flex: 1,
319316
},
317+
header: {
318+
zIndex: 10,
319+
},
320320
});
321321

322322
export default ScrollViewStickyHeader;

packages/react-native/Libraries/Components/Touchable/TouchableBounce.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,14 @@ class TouchableBounce extends React.Component<
4747

4848
_createPressabilityConfig(): PressabilityConfig {
4949
return {
50+
android_disableSound: this.props.touchSoundDisabled,
5051
cancelable: !this.props.rejectResponderTermination,
51-
disabled: this.props.disabled,
52-
hitSlop: this.props.hitSlop,
5352
delayLongPress: this.props.delayLongPress,
5453
delayPressIn: this.props.delayPressIn,
5554
delayPressOut: this.props.delayPressOut,
55+
disabled: this.props.disabled,
56+
hitSlop: this.props.hitSlop,
5657
minPressDuration: 0,
57-
pressRectOffset: this.props.pressRetentionOffset,
58-
android_disableSound: this.props.touchSoundDisabled,
5958
onBlur: event => {
6059
if (Platform.isTV) {
6160
this._bounceTo(1, 0.4, 0);
@@ -113,6 +112,7 @@ class TouchableBounce extends React.Component<
113112
this.props.onPressOut(event);
114113
}
115114
},
115+
pressRectOffset: this.props.pressRetentionOffset,
116116
};
117117
}
118118

@@ -123,10 +123,10 @@ class TouchableBounce extends React.Component<
123123
callback?: ?() => void,
124124
) {
125125
Animated.spring(this.state.scale, {
126-
toValue,
127-
velocity,
128126
bounciness,
127+
toValue,
129128
useNativeDriver: true,
129+
velocity,
130130
}).start(callback);
131131
}
132132

@@ -230,6 +230,6 @@ export default (function TouchableBounceWrapper({
230230
}) {
231231
return <TouchableBounce {...props} hostRef={hostRef} />;
232232
} as component(
233-
ref: React.RefSetter<mixed>,
233+
ref?: React.RefSetter<mixed>,
234234
...props: $ReadOnly<Omit<TouchableBounceProps, 'hostRef'>>
235235
));

packages/react-native/Libraries/Debugging/DebuggingOverlay.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,13 @@ function DebuggingOverlay({
3939
useImperativeHandle(
4040
ref,
4141
() => ({
42-
highlightTraceUpdates(updates) {
42+
clearElementsHighlight() {
4343
if (!isNativeComponentReady) {
4444
return;
4545
}
4646

47-
const nonEmptyRectangles = updates.filter(
48-
({rectangle, color}) => rectangle.width >= 0 && rectangle.height >= 0,
49-
);
50-
5147
if (nativeComponentRef.current != null) {
52-
Commands.highlightTraceUpdates(
53-
nativeComponentRef.current,
54-
nonEmptyRectangles,
55-
);
48+
Commands.clearElementsHighlights(nativeComponentRef.current);
5649
}
5750
},
5851
highlightElements(elements) {
@@ -64,13 +57,20 @@ function DebuggingOverlay({
6457
Commands.highlightElements(nativeComponentRef.current, elements);
6558
}
6659
},
67-
clearElementsHighlight() {
60+
highlightTraceUpdates(updates) {
6861
if (!isNativeComponentReady) {
6962
return;
7063
}
7164

65+
const nonEmptyRectangles = updates.filter(
66+
({rectangle, color}) => rectangle.width >= 0 && rectangle.height >= 0,
67+
);
68+
7269
if (nativeComponentRef.current != null) {
73-
Commands.clearElementsHighlights(nativeComponentRef.current);
70+
Commands.highlightTraceUpdates(
71+
nativeComponentRef.current,
72+
nonEmptyRectangles,
73+
);
7474
}
7575
},
7676
}),
@@ -95,14 +95,14 @@ function DebuggingOverlay({
9595

9696
const styles = StyleSheet.create({
9797
overlay: {
98-
position: 'absolute',
99-
top: 0,
10098
bottom: 0,
10199
left: 0,
100+
position: 'absolute',
102101
right: 0,
102+
top: 0,
103103
},
104104
});
105105

106106
export default DebuggingOverlay as component(
107-
ref: React.RefSetter<DebuggingOverlayHandle>,
107+
ref?: React.RefSetter<DebuggingOverlayHandle>,
108108
);

packages/react-native/ReactNativeApi.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<4ccde3daef50fa7522f10bc7146c0cc6>>
7+
* @generated SignedSource<<377660a4dc9f8c721ebcd64f759637ac>>
88
*
99
* This file was generated by scripts/js-api/build-types/index.js.
1010
*/
@@ -573,7 +573,7 @@ declare const VirtualizedSectionListComponent_default: <
573573
> = DefaultVirtualizedSectionT,
574574
>(
575575
props: Omit<VirtualizedSectionListProps<ItemT, SectionT>, "ref"> & {
576-
ref: React.Ref<{
576+
ref?: React.Ref<{
577577
getListRef(): undefined | VirtualizedList_default
578578
scrollToLocation(params: ScrollToLocationParamsType): void
579579
}>

packages/rn-tester/js/examples/FlatList/BaseFlatListExample.js

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ type Props = $ReadOnly<{
6868
}>;
6969

7070
const BaseFlatListExample: component(
71-
ref: React.RefSetter<FlatList<string>>,
71+
ref?: React.RefSetter<FlatList<string>>,
7272
...props: Props
7373
) = ({ref, ...props}: {ref: React.RefSetter<FlatList<string>>, ...Props}) => {
7474
return (
@@ -111,41 +111,23 @@ const ITEM_MARGIN = 8;
111111
export const ITEM_HEIGHT: number = ITEM_INNER_HEIGHT + ITEM_MARGIN * 2;
112112

113113
const styles = StyleSheet.create({
114+
container: {flex: 1},
115+
header: {
116+
backgroundColor: 'white',
117+
fontSize: 32,
118+
},
114119
item: {
115120
backgroundColor: 'pink',
116-
paddingHorizontal: 20,
117121
height: ITEM_INNER_HEIGHT,
118-
marginVertical: ITEM_MARGIN,
119122
justifyContent: 'center',
123+
marginVertical: ITEM_MARGIN,
124+
paddingHorizontal: 20,
120125
},
121-
header: {
122-
fontSize: 32,
123-
backgroundColor: 'white',
124-
},
125-
title: {
126-
fontSize: 24,
127-
},
128-
titleContainer: {
129-
position: 'absolute',
130-
top: 45,
131-
left: 0,
132-
right: 0,
133-
justifyContent: 'flex-end',
134-
alignItems: 'center',
135-
backgroundColor: 'gray',
136-
zIndex: 1,
137-
},
138-
titleText: {
139-
fontSize: 24,
140-
lineHeight: 44,
141-
fontWeight: 'bold',
126+
list: {
127+
flex: 1,
142128
},
143-
testContainer: {
144-
flexDirection: 'row',
145-
justifyContent: 'space-between',
146-
alignItems: 'center',
147-
backgroundColor: '#f2f2f7ff',
148-
height: 40,
129+
offScreen: {
130+
height: 1000,
149131
},
150132
output: {
151133
fontSize: 12,
@@ -156,11 +138,29 @@ const styles = StyleSheet.create({
156138
separatorText: {
157139
fontSize: 10,
158140
},
159-
list: {
160-
flex: 1,
141+
testContainer: {
142+
alignItems: 'center',
143+
backgroundColor: '#f2f2f7ff',
144+
flexDirection: 'row',
145+
height: 40,
146+
justifyContent: 'space-between',
161147
},
162-
container: {flex: 1},
163-
offScreen: {
164-
height: 1000,
148+
title: {
149+
fontSize: 24,
150+
},
151+
titleContainer: {
152+
alignItems: 'center',
153+
backgroundColor: 'gray',
154+
justifyContent: 'flex-end',
155+
left: 0,
156+
position: 'absolute',
157+
right: 0,
158+
top: 45,
159+
zIndex: 1,
160+
},
161+
titleText: {
162+
fontSize: 24,
163+
fontWeight: 'bold',
164+
lineHeight: 44,
165165
},
166166
});

packages/rn-tester/js/examples/SectionList/SectionListBaseExample.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ import {
2020

2121
const DATA = [
2222
{
23-
title: 'Main dishes',
2423
data: ['Pizza', 'Burger', 'Risotto'],
24+
title: 'Main dishes',
2525
},
2626
{
27-
title: 'Sides',
2827
data: ['French Fries', 'Onion Rings', 'Fried Shrimps'],
28+
title: 'Sides',
2929
},
3030
{
31-
title: 'Drinks',
3231
data: ['Water', 'Coke', 'Beer'],
32+
title: 'Drinks',
3333
},
3434
{
35-
title: 'Desserts',
3635
data: ['Cheesecake', 'Brownie'],
36+
title: 'Desserts',
3737
},
3838
];
3939

@@ -75,7 +75,7 @@ type Props = $ReadOnly<{
7575

7676
const SectionListBaseExample: component(
7777
// $FlowFixMe[unclear-type]
78-
ref: React.RefSetter<SectionList<any>>,
78+
ref?: React.RefSetter<SectionList<any>>,
7979
...props: Props
8080
) = ({
8181
ref,
@@ -122,33 +122,33 @@ const SectionListBaseExample: component(
122122
};
123123

124124
const styles = StyleSheet.create({
125+
container: {flex: 1},
126+
header: {
127+
backgroundColor: 'white',
128+
fontSize: 32,
129+
},
125130
item: {
126131
backgroundColor: 'pink',
127-
padding: 20,
128132
marginVertical: 8,
133+
padding: 20,
129134
},
130-
header: {
131-
fontSize: 32,
132-
backgroundColor: 'white',
135+
list: {
136+
flex: 1,
133137
},
134-
title: {
135-
fontSize: 24,
138+
output: {
139+
flex: 1,
140+
fontSize: 12,
136141
},
137142
testContainer: {
138-
flexDirection: 'row',
139-
justifyContent: 'space-between',
140143
alignItems: 'center',
141144
backgroundColor: '#f2f2f7ff',
145+
flexDirection: 'row',
142146
height: 40,
147+
justifyContent: 'space-between',
143148
},
144-
output: {
145-
flex: 1,
146-
fontSize: 12,
147-
},
148-
list: {
149-
flex: 1,
149+
title: {
150+
fontSize: 24,
150151
},
151-
container: {flex: 1},
152152
});
153153

154154
export default SectionListBaseExample;

packages/rn-tester/js/examples/TextInput/ExampleTextInput.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import React, {useContext} from 'react';
1313
import {StyleSheet, TextInput} from 'react-native';
1414

1515
const ExampleTextInput: component(
16-
ref: React.RefSetter<null | React.ElementRef<typeof TextInput>>,
16+
ref?: React.RefSetter<null | React.ElementRef<typeof TextInput>>,
1717
...props: React.ElementConfig<typeof TextInput>
1818
) = ({
1919
ref,
@@ -30,9 +30,9 @@ const ExampleTextInput: component(
3030
{...props}
3131
style={[
3232
{
33-
color: theme.LabelColor,
3433
backgroundColor: theme.SecondaryGroupedBackgroundColor,
3534
borderColor: theme.QuaternaryLabelColor,
35+
color: theme.LabelColor,
3636
},
3737
styles.input,
3838
props.style,
@@ -44,9 +44,9 @@ const ExampleTextInput: component(
4444
const styles = StyleSheet.create({
4545
input: {
4646
borderWidth: 1,
47-
fontSize: 13,
4847
flexGrow: 1,
4948
flexShrink: 1,
49+
fontSize: 13,
5050
padding: 4,
5151
},
5252
});

packages/virtualized-lists/Lists/VirtualizedSectionList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ const VirtualizedSectionListComponent = VirtualizedSectionList as component<
648648
DefaultVirtualizedSectionT,
649649
> = DefaultVirtualizedSectionT,
650650
>(
651-
ref: React.RefSetter<
651+
ref?: React.RefSetter<
652652
interface {
653653
getListRef(): ?VirtualizedList,
654654
scrollToLocation(params: ScrollToLocationParamsType): void,

0 commit comments

Comments
 (0)