mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Eliminate 2 more remaining React.AbstractComponent<...> in react native
Summary: In order to adopt react 19's ref-as-prop model, we need to eliminate all the places where they are treated differently. `React.AbstractComponent` is the worst example of this, and we need to eliminate it. This diff replaces 2 more remaining ones in react-native. Now the only remaining one is the one synced from react repo. Changelog: [Internal] Reviewed By: alexmckenley Differential Revision: D64722899 fbshipit-source-id: 2b2484c385fc5d6c173253f9bee66dfc736368a5
This commit is contained in:
committed by
Facebook GitHub Bot
parent
71e9039e9f
commit
036e4f64c4
@@ -35,18 +35,18 @@ export type StrictAnimatedProps<Props: {...}> = $ReadOnly<{
|
||||
passthroughAnimatedPropExplicitValues?: ?Props,
|
||||
}>;
|
||||
|
||||
export type AnimatedComponentType<
|
||||
Props: {...},
|
||||
+Instance = mixed,
|
||||
> = React.AbstractComponent<AnimatedProps<Props>, Instance>;
|
||||
export type AnimatedComponentType<Props: {...}, +Instance = mixed> = component(
|
||||
ref: React.RefSetter<Instance>,
|
||||
...AnimatedProps<Props>
|
||||
);
|
||||
|
||||
export type StrictAnimatedComponentType<
|
||||
Props: {...},
|
||||
+Instance = mixed,
|
||||
> = React.AbstractComponent<StrictAnimatedProps<Props>, Instance>;
|
||||
> = component(ref: React.RefSetter<Instance>, ...StrictAnimatedProps<Props>);
|
||||
|
||||
export default function createAnimatedComponent<TProps: {...}, TInstance>(
|
||||
Component: React.AbstractComponent<TProps, TInstance>,
|
||||
Component: component(ref: React.RefSetter<TInstance>, ...TProps),
|
||||
): AnimatedComponentType<TProps, TInstance> {
|
||||
return unstable_createAnimatedComponentWithAllowlist(Component, null);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ export function unstable_createAnimatedComponentWithAllowlist<
|
||||
TProps: {...},
|
||||
TInstance,
|
||||
>(
|
||||
Component: React.AbstractComponent<TProps, TInstance>,
|
||||
Component: component(ref: React.RefSetter<TInstance>, ...TProps),
|
||||
allowlist: ?AnimatedPropsAllowlist,
|
||||
): StrictAnimatedComponentType<TProps, TInstance> {
|
||||
const AnimatedComponent = React.forwardRef<
|
||||
|
||||
+2
-2
@@ -275,12 +275,12 @@ const ScrollViewStickyHeaderWithForwardedRef: component(
|
||||
: null;
|
||||
|
||||
return (
|
||||
/* $FlowFixMe[prop-missing] passthroughAnimatedPropExplicitValues isn't properly
|
||||
included in the Animated.View flow type. */
|
||||
<Animated.View
|
||||
collapsable={false}
|
||||
nativeID={props.nativeID}
|
||||
onLayout={_onLayout}
|
||||
/* $FlowFixMe[prop-missing] passthroughAnimatedPropExplicitValues isn't properly
|
||||
included in the Animated.View flow type. */
|
||||
ref={ref}
|
||||
style={[
|
||||
child.props.style,
|
||||
|
||||
@@ -189,6 +189,7 @@ class TouchableBounce extends React.Component<Props, State> {
|
||||
this.props.onPress !== undefined &&
|
||||
!this.props.disabled
|
||||
}
|
||||
// $FlowFixMe[prop-missing]
|
||||
ref={this.props.hostRef}
|
||||
{...eventHandlersWithoutBlurAndFocus}>
|
||||
{this.props.children}
|
||||
|
||||
@@ -291,6 +291,7 @@ class TouchableOpacity extends React.Component<Props, State> {
|
||||
this.props.onPress !== undefined &&
|
||||
!this.props.disabled
|
||||
}
|
||||
// $FlowFixMe[prop-missing]
|
||||
ref={this.props.hostRef}
|
||||
{...eventHandlersWithoutBlurAndFocus}>
|
||||
{this.props.children}
|
||||
|
||||
@@ -16,7 +16,7 @@ import type {
|
||||
SectionBase as _SectionBase,
|
||||
VirtualizedSectionListProps,
|
||||
} from '@react-native/virtualized-lists';
|
||||
import type {AbstractComponent, ElementRef} from 'react';
|
||||
import type {ElementRef} from 'react';
|
||||
|
||||
import Platform from '../Utilities/Platform';
|
||||
import {VirtualizedSectionList} from '@react-native/virtualized-lists';
|
||||
|
||||
@@ -744,22 +744,22 @@ export type StrictAnimatedProps<Props: { ... }> = $ReadOnly<{
|
||||
export type AnimatedComponentType<
|
||||
Props: { ... },
|
||||
+Instance = mixed,
|
||||
> = React.AbstractComponent<AnimatedProps<Props>, Instance>;
|
||||
> = component(ref: React.RefSetter<Instance>, ...AnimatedProps<Props>);
|
||||
export type StrictAnimatedComponentType<
|
||||
Props: { ... },
|
||||
+Instance = mixed,
|
||||
> = React.AbstractComponent<StrictAnimatedProps<Props>, Instance>;
|
||||
> = component(ref: React.RefSetter<Instance>, ...StrictAnimatedProps<Props>);
|
||||
declare export default function createAnimatedComponent<
|
||||
TProps: { ... },
|
||||
TInstance,
|
||||
>(
|
||||
Component: React.AbstractComponent<TProps, TInstance>
|
||||
Component: component(ref: React.RefSetter<TInstance>, ...TProps)
|
||||
): AnimatedComponentType<TProps, TInstance>;
|
||||
declare export function unstable_createAnimatedComponentWithAllowlist<
|
||||
TProps: { ... },
|
||||
TInstance,
|
||||
>(
|
||||
Component: React.AbstractComponent<TProps, TInstance>,
|
||||
Component: component(ref: React.RefSetter<TInstance>, ...TProps),
|
||||
allowlist: ?AnimatedPropsAllowlist
|
||||
): StrictAnimatedComponentType<TProps, TInstance>;
|
||||
"
|
||||
|
||||
Reference in New Issue
Block a user