diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 69e63090ea32d5..ebd06871906c49 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -634,10 +634,11 @@ class VirtualizedList extends React.PureComponent { _registerAsNestedChild = (childList: { cellKey: string, key: string, - ref: VirtualizedList, + ref: React.ElementRef, parentDebugInfo: ListDebugInfo, ... }): ?ChildListState => { + const specificRef = ((childList.ref: any): VirtualizedList); // Register the mapping between this child key and the cellKey for its cell const childListsInCell = this._cellKeysToChildListKeys.get(childList.cellKey) || new Set(); @@ -651,19 +652,20 @@ class VirtualizedList extends React.PureComponent { 'list. You must pass a unique listKey prop to each sibling list.\n\n' + describeNestedLists({ ...childList, + ref: specificRef, // We're called from the child's componentDidMount, so it's safe to // read the child's props here (albeit weird). - horizontal: !!childList.ref.props.horizontal, + horizontal: !!specificRef.props.horizontal, }), ); } this._nestedChildLists.set(childList.key, { - ref: childList.ref, + ref: specificRef, state: null, }); if (this._hasInteracted) { - childList.ref.recordInteraction(); + specificRef.recordInteraction(); } }; diff --git a/Libraries/Lists/VirtualizedListContext.js b/Libraries/Lists/VirtualizedListContext.js index 308f6a20d19a54..a17c4b19160a1b 100644 --- a/Libraries/Lists/VirtualizedListContext.js +++ b/Libraries/Lists/VirtualizedListContext.js @@ -8,7 +8,6 @@ * @format */ -import type VirtualizedList from './VirtualizedList.js'; import * as React from 'react'; import {useMemo, useContext} from 'react'; @@ -50,12 +49,12 @@ type Context = $ReadOnly<{ zoomScale: number, }, horizontal: ?boolean, - getOutermostParentListRef: () => VirtualizedList, + getOutermostParentListRef: () => React.ElementRef, getNestedChildState: string => ?ChildListState, registerAsNestedChild: ({ cellKey: string, key: string, - ref: VirtualizedList, + ref: React.ElementRef, parentDebugInfo: ListDebugInfo, }) => ?ChildListState, unregisterAsNestedChild: ({