From ca1a642060f248969810997536cb07b4d3d9a301 Mon Sep 17 00:00:00 2001 From: Anne Pham Date: Wed, 31 Aug 2022 15:58:38 -0700 Subject: [PATCH 1/3] Add a check for scrollEnabled to VirtualizedList error --- Libraries/Lists/VirtualizedList.js | 4 +++- Libraries/Lists/VirtualizedListProps.js | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 2e06c88e6eac..0e761292f251 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -848,6 +848,7 @@ class VirtualizedList extends React.PureComponent { onScrollEndDrag: this._onScrollEndDrag, onMomentumScrollBegin: this._onMomentumScrollBegin, onMomentumScrollEnd: this._onMomentumScrollEnd, + scrollEnabled: this.props.scrollEnabled, scrollEventThrottle: scrollEventThrottleOrDefault( this.props.scrollEventThrottle, ), // TODO: Android support @@ -898,7 +899,8 @@ class VirtualizedList extends React.PureComponent { !scrollContext.horizontal === !horizontalOrDefault(this.props.horizontal) && !this._hasWarned.nesting && - this.context == null + this.context == null && + this.props.scrollEnabled === true ) { // TODO (T46547044): use React.warn once 16.9 is sync'd: https://github.com/facebook/react/pull/15170 console.error( diff --git a/Libraries/Lists/VirtualizedListProps.js b/Libraries/Lists/VirtualizedListProps.js index 7bf0cd0f5397..53514e757131 100644 --- a/Libraries/Lists/VirtualizedListProps.js +++ b/Libraries/Lists/VirtualizedListProps.js @@ -264,6 +264,12 @@ type OptionalProps = {| * The legacy implementation is no longer supported. */ legacyImplementation?: empty, + + /** + * When false, the view cannot be scrolled via touch interaction. + * Default value is true. + */ + scrollEnabled?: boolean, |}; export type Props = {| From 109cb42afd6cbe12d4eaade90a57c57e194a4d69 Mon Sep 17 00:00:00 2001 From: Anne Pham Date: Wed, 31 Aug 2022 15:58:38 -0700 Subject: [PATCH 2/3] Add a check for scrollEnabled to VirtualizedList error --- Libraries/Lists/VirtualizedList.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 2e06c88e6eac..8f79a7053292 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -898,7 +898,8 @@ class VirtualizedList extends React.PureComponent { !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( From 503e311addc9d5dd232fed69d6dd70a8feba5d1c Mon Sep 17 00:00:00 2001 From: Anne Pham Date: Tue, 6 Sep 2022 10:44:30 -0700 Subject: [PATCH 3/3] added to VirtualizedList_EXPERIMENTAL --- Libraries/Lists/VirtualizedList.js | 3 +-- Libraries/Lists/VirtualizedList_EXPERIMENTAL.js | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 8f79a7053292..2e06c88e6eac 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -898,8 +898,7 @@ class VirtualizedList extends React.PureComponent { !scrollContext.horizontal === !horizontalOrDefault(this.props.horizontal) && !this._hasWarned.nesting && - this.context == null && - this.props.scrollEnabled !== false + this.context == null ) { // TODO (T46547044): use React.warn once 16.9 is sync'd: https://github.com/facebook/react/pull/15170 console.error( diff --git a/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js b/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js index d08f2610fc37..ec69b9c695e9 100644 --- a/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js +++ b/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js @@ -1093,7 +1093,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(