From c00f0d36b1019f12c05dad2e730c337beae85e34 Mon Sep 17 00:00:00 2001 From: Fabrizio Cucci Date: Thu, 10 Oct 2024 10:59:58 -0700 Subject: [PATCH] Replace React.AbstractComponent with `component` type in ScrollView (#46927) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46927 Prepare for the ref-as-prop typing change in flow. Changelog: [Internal] Reviewed By: SamChou19815 Differential Revision: D64112934 fbshipit-source-id: d869ccd814cd3bbda2a548c7c2d405f651605716 --- .../Libraries/Components/ScrollView/ScrollView.js | 10 +++++----- .../__tests__/__snapshots__/public-api-test.js.snap | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/react-native/Libraries/Components/ScrollView/ScrollView.js b/packages/react-native/Libraries/Components/ScrollView/ScrollView.js index 8d2bb60fde6..39740a8ae59 100644 --- a/packages/react-native/Libraries/Components/ScrollView/ScrollView.js +++ b/packages/react-native/Libraries/Components/ScrollView/ScrollView.js @@ -1935,7 +1935,10 @@ function createRefForwarder( // NOTE: This wrapper component is necessary because `ScrollView` is a class // component and we need to map `ref` to a differently named prop. This can be // removed when `ScrollView` is a functional component. -const Wrapper = React.forwardRef(function Wrapper( +const Wrapper: component( + ref: React.RefSetter, + ...props: Props +) = React.forwardRef(function Wrapper( props: Props, ref: ?React.RefSetter, ): React.Node { @@ -1949,8 +1952,5 @@ Wrapper.displayName = 'ScrollView'; // $FlowExpectedError[prop-missing] Wrapper.Context = ScrollViewContext; -module.exports = ((Wrapper: $FlowFixMe): React.AbstractComponent< - React.ElementConfig, - PublicScrollViewInstance, -> & +module.exports = ((Wrapper: $FlowFixMe): typeof Wrapper & ScrollViewComponentStatics); diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index 2c44b30437d..5c8c3990c91 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -2258,11 +2258,11 @@ type RefForwarder = { nativeInstance: TNativeInstance | null, publicInstance: TPublicInstance | null, }; -declare module.exports: React.AbstractComponent< - React.ElementConfig, - PublicScrollViewInstance, -> & - ScrollViewComponentStatics; +declare const Wrapper: component( + ref: React.RefSetter, + ...props: Props +); +declare module.exports: typeof Wrapper & ScrollViewComponentStatics; " `;