Skip to content

Commit fe4047f

Browse files
j-piaseckifacebook-github-bot
authored andcommitted
Replace ElementConfig with directly imported props (#51971)
Summary: Pull Request resolved: #51971 Changelog: [Internal] Reviewed By: huntie Differential Revision: D76502294 fbshipit-source-id: ed98c5e6d9ef5fd6a4d1adbd6a88ce8cda52b969
1 parent 9f479ff commit fe4047f

File tree

7 files changed

+23
-33
lines changed

7 files changed

+23
-33
lines changed

packages/react-native/Libraries/Animated/components/AnimatedScrollView.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import type {
1515
} from '../createAnimatedComponent';
1616

1717
import RefreshControl from '../../Components/RefreshControl/RefreshControl';
18-
import ScrollView from '../../Components/ScrollView/ScrollView';
18+
import ScrollView, {
19+
type ScrollViewProps,
20+
} from '../../Components/ScrollView/ScrollView';
1921
import flattenStyle from '../../StyleSheet/flattenStyle';
2022
import splitLayoutProps from '../../StyleSheet/splitLayoutProps';
2123
import StyleSheet from '../../StyleSheet/StyleSheet';
@@ -26,21 +28,20 @@ import useAnimatedProps from '../useAnimatedProps';
2628
import * as React from 'react';
2729
import {cloneElement, useMemo} from 'react';
2830

29-
type AnimatedScrollViewProps = React.ElementConfig<typeof ScrollView>;
3031
type AnimatedScrollViewInstance = React.ElementRef<typeof ScrollView>;
3132

3233
/**
3334
* @see https://github.com/facebook/react-native/commit/b8c8562
3435
*/
3536
const AnimatedScrollView: AnimatedComponentType<
36-
AnimatedScrollViewProps,
37+
ScrollViewProps,
3738
AnimatedScrollViewInstance,
3839
> = function AnimatedScrollViewWithOrWithoutInvertedRefreshControl({
3940
ref: forwardedRef,
4041
...props
4142
}: {
4243
ref?: React.RefSetter<AnimatedScrollViewInstance>,
43-
...AnimatedProps<AnimatedScrollViewProps>,
44+
...AnimatedProps<ScrollViewProps>,
4445
}) {
4546
// (Android only) When a ScrollView has a RefreshControl and
4647
// any `style` property set with an Animated.Value, the CSS
@@ -111,7 +112,7 @@ const AnimatedScrollViewWithInvertedRefreshControl =
111112

112113
// Handle animated props on `NativeDirectionalScrollView`.
113114
const [scrollViewAnimatedProps, scrollViewRef] = useAnimatedProps<
114-
AnimatedScrollViewProps,
115+
ScrollViewProps,
115116
AnimatedScrollViewInstance,
116117
>(intermediatePropsForScrollView);
117118
const ref = useMergeRefs<AnimatedScrollViewInstance>(

packages/react-native/Libraries/Animated/components/AnimatedText.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@
1010

1111
import type {AnimatedComponentType} from '../createAnimatedComponent';
1212

13-
import Text from '../../Text/Text';
13+
import Text, {type TextProps} from '../../Text/Text';
1414
import createAnimatedComponent from '../createAnimatedComponent';
1515
import * as React from 'react';
1616

1717
export default (createAnimatedComponent(
1818
(Text: $FlowFixMe),
19-
): AnimatedComponentType<
20-
React.ElementConfig<typeof Text>,
21-
React.ElementRef<typeof Text>,
22-
>);
19+
): AnimatedComponentType<TextProps, React.ElementRef<typeof Text>>);

packages/react-native/Libraries/Animated/components/AnimatedView.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
* @format
99
*/
1010

11+
import type {ViewProps} from '../../Components/View/ViewPropTypes';
1112
import type {AnimatedComponentType} from '../createAnimatedComponent';
1213

1314
import View from '../../Components/View/View';
1415
import createAnimatedComponent from '../createAnimatedComponent';
1516
import * as React from 'react';
1617

1718
export default (createAnimatedComponent(View): AnimatedComponentType<
18-
React.ElementConfig<typeof View>,
19+
ViewProps,
1920
React.ElementRef<typeof View>,
2021
>);

packages/react-native/Libraries/Animated/createAnimatedComponent.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import type AnimatedValue from './nodes/AnimatedValue';
2121

2222
import createAnimatedPropsHook from '../../src/private/animated/createAnimatedPropsHook';
2323
import composeStyles from '../../src/private/styles/composeStyles';
24-
import View from '../Components/View/View';
24+
import {type ViewProps} from '../Components/View/ViewPropTypes';
2525
import useMergeRefs from '../Utilities/useMergeRefs';
2626
import * as React from 'react';
2727
import {useMemo} from 'react';
@@ -60,9 +60,7 @@ type NonAnimatedProps =
6060
| 'disabled'
6161
| 'accessibilityLabel';
6262
type PassThroughProps = $ReadOnly<{
63-
passthroughAnimatedPropExplicitValues?: React.ElementConfig<
64-
typeof View,
65-
> | null,
63+
passthroughAnimatedPropExplicitValues?: ViewProps | null,
6664
}>;
6765

6866
export type AnimatedProps<Props: {...}> = {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @format
99
*/
1010

11+
import type {ViewStyleProp} from '../../StyleSheet/StyleSheet';
1112
import type {
1213
GestureResponderEvent,
1314
LayoutChangeEvent,
@@ -26,8 +27,6 @@ import useAndroidRippleForView, {
2627
import * as React from 'react';
2728
import {memo, useMemo, useRef, useState} from 'react';
2829

29-
type ViewStyleProp = React.ElementConfig<typeof View>['style'];
30-
3130
export type {PressableAndroidRippleConfig};
3231

3332
export type PressableStateCallbackType = $ReadOnly<{

packages/react-native/Libraries/Lists/FlatList.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ import type {
2020
import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
2121
import {type ScrollResponderType} from '../Components/ScrollView/ScrollView';
2222
import View from '../Components/View/View';
23-
import VirtualizedLists from '@react-native/virtualized-lists';
23+
import VirtualizedLists, {
24+
type VirtualizedListProps,
25+
} from '@react-native/virtualized-lists';
2426
import memoizeOne from 'memoize-one';
2527
import * as React from 'react';
2628

@@ -181,8 +183,6 @@ type FlatListBaseProps<ItemT> = {
181183
...OptionalProps<ItemT>,
182184
};
183185

184-
type VirtualizedListProps = React.ElementConfig<typeof VirtualizedList>;
185-
186186
export type FlatListProps<ItemT> = {
187187
...Omit<
188188
VirtualizedListProps,

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -628,10 +628,9 @@ exports[`public API should not change unintentionally Libraries/Animated/compone
628628
`;
629629

630630
exports[`public API should not change unintentionally Libraries/Animated/components/AnimatedScrollView.js 1`] = `
631-
"type AnimatedScrollViewProps = React.ElementConfig<typeof ScrollView>;
632-
type AnimatedScrollViewInstance = React.ElementRef<typeof ScrollView>;
631+
"type AnimatedScrollViewInstance = React.ElementRef<typeof ScrollView>;
633632
declare const AnimatedScrollView: AnimatedComponentType<
634-
AnimatedScrollViewProps,
633+
ScrollViewProps,
635634
AnimatedScrollViewInstance,
636635
>;
637636
declare export default typeof AnimatedScrollView;
@@ -648,15 +647,15 @@ exports[`public API should not change unintentionally Libraries/Animated/compone
648647

649648
exports[`public API should not change unintentionally Libraries/Animated/components/AnimatedText.js 1`] = `
650649
"declare export default AnimatedComponentType<
651-
React.ElementConfig<typeof Text>,
650+
TextProps,
652651
React.ElementRef<typeof Text>,
653652
>;
654653
"
655654
`;
656655

657656
exports[`public API should not change unintentionally Libraries/Animated/components/AnimatedView.js 1`] = `
658657
"declare export default AnimatedComponentType<
659-
React.ElementConfig<typeof View>,
658+
ViewProps,
660659
React.ElementRef<typeof View>,
661660
>;
662661
"
@@ -695,9 +694,7 @@ type NonAnimatedProps =
695694
| \\"disabled\\"
696695
| \\"accessibilityLabel\\";
697696
type PassThroughProps = $ReadOnly<{
698-
passthroughAnimatedPropExplicitValues?: React.ElementConfig<
699-
typeof View,
700-
> | null,
697+
passthroughAnimatedPropExplicitValues?: ViewProps | null,
701698
}>;
702699
export type AnimatedProps<Props: { ... }> = {
703700
[K in keyof Props]: K extends NonAnimatedProps
@@ -1757,8 +1754,7 @@ declare export default typeof LayoutConformanceNativeComponent;
17571754
`;
17581755

17591756
exports[`public API should not change unintentionally Libraries/Components/Pressable/Pressable.js 1`] = `
1760-
"type ViewStyleProp = React.ElementConfig<typeof View>[\\"style\\"];
1761-
export type { PressableAndroidRippleConfig };
1757+
"export type { PressableAndroidRippleConfig };
17621758
export type PressableStateCallbackType = $ReadOnly<{
17631759
pressed: boolean,
17641760
}>;
@@ -4940,8 +4936,7 @@ declare export default typeof FillRateHelper;
49404936
`;
49414937

49424938
exports[`public API should not change unintentionally Libraries/Lists/FlatList.js 1`] = `
4943-
"declare const VirtualizedList: typeof VirtualizedLists.VirtualizedList;
4944-
type RequiredProps<ItemT> = {
4939+
"type RequiredProps<ItemT> = {
49454940
data: ?$ReadOnly<$ArrayLike<ItemT>>,
49464941
};
49474942
type OptionalProps<ItemT> = {
@@ -4971,7 +4966,6 @@ type FlatListBaseProps<ItemT> = {
49714966
...RequiredProps<ItemT>,
49724967
...OptionalProps<ItemT>,
49734968
};
4974-
type VirtualizedListProps = React.ElementConfig<typeof VirtualizedList>;
49754969
export type FlatListProps<ItemT> = {
49764970
...Omit<
49774971
VirtualizedListProps,

0 commit comments

Comments
 (0)