Skip to content

Commit

Permalink
filter out onContentSizeChange from defaultRenderScrollComponent (#41113
Browse files Browse the repository at this point in the history
)

Summary:
Pull Request resolved: #41113

changelog: [internal]

We must prevent VirtualizedList._onContentSizeChange from being triggered by a conflicting bubbling onContentSizeChange event.
For TextInput, we change the event onContentSizeChange from bubbling to direct (744fb4a). To make this safer, we need to filter out any `onContentSizeChange` event since we can't control 3rd party components from dispatching onContentSizeChange as bubbling event.

Reviewed By: NickGerleman

Differential Revision: D50451232

fbshipit-source-id: b7a446e4efc9c45024d37f35cb53f2fcbb28799f
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Oct 23, 2023
1 parent 0239776 commit e8a0f0d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/virtualized-lists/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -1257,8 +1257,10 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
_defaultRenderScrollComponent = props => {
const onRefresh = props.onRefresh;
if (this._isNestedWithSameOrientation()) {
// $FlowFixMe[prop-missing] - Typing ReactNativeComponent revealed errors
return <View {...props} />;
// Prevent VirtualizedList._onContentSizeChange from being triggered by a bubbling onContentSizeChange event.
// This could lead to internal inconsistencies within VirtualizedList.
const {onContentSizeChange, ...otherProps} = props;
return <View {...otherProps} />;
} else if (onRefresh) {
invariant(
typeof props.refreshing === 'boolean',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@ exports[`VirtualizedList handles nested lists 1`] = `
getItem={[Function]}
getItemCount={[Function]}
horizontal={false}
onContentSizeChange={[Function]}
onLayout={[Function]}
onMomentumScrollBegin={[Function]}
onMomentumScrollEnd={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ exports[`VirtualizedSectionList handles nested lists 1`] = `
getItemCount={[Function]}
horizontal={false}
keyExtractor={[Function]}
onContentSizeChange={[Function]}
onLayout={[Function]}
onMomentumScrollBegin={[Function]}
onMomentumScrollEnd={[Function]}
Expand Down

0 comments on commit e8a0f0d

Please sign in to comment.