From 62f83a9fad027ef0ed808f7e34973bb01cdf10e9 Mon Sep 17 00:00:00 2001 From: Anne Pham Date: Wed, 7 Sep 2022 19:10:01 -0700 Subject: [PATCH] Add a check for scrollEnabled to VirtualizedList error (#34560) Summary: Nested `VirtualizedList` is now an [error](https://github.com/facebook/react-native/commit/646605b90e666c4b0d1c1200a137eacf62b46f87), instead of a warning. Issues [here](https://github.com/facebook/react-native/issues/31697) and [here](https://github.com/facebook/react-native/issues/33024) outline the concern. ## Changelog [General] [Added] - Added a check to if `scrollEnabled` is not false, if so then fire the `VirtualizedList` error Pull Request resolved: https://github.com/facebook/react-native/pull/34560 Test Plan: Passes all provided automatic tests. In a personal app, there is a situation of nested ScrollViews that had triggered the error. After defining `scrollEnabled={false}` and adding the check, the error no longer appears. Reviewed By: yungsters Differential Revision: D39283866 Pulled By: NickGerleman fbshipit-source-id: 16ae6bbe6bb8b01a54ae18f9e6abf75d11c21c29 --- Libraries/Lists/VirtualizedList_EXPERIMENTAL.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js b/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js index 50b867e6cbfaa1..dcad121319835a 100644 --- a/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js +++ b/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js @@ -1101,7 +1101,8 @@ class VirtualizedList extends StateSafePureComponent { !scrollContext.horizontal === !horizontalOrDefault(this.props.horizontal) && !this._hasWarned.nesting && - this.context == null + this.context == null && + this.props.scrollEnabled !== false ) { // TODO (T46547044): use React.warn once 16.9 is sync'd: https://github.com/facebook/react/pull/15170 console.error(