Skip to content

Commit

Permalink
Enable removeClippedSubviews on Android only for improved scrolling p…
Browse files Browse the repository at this point in the history
…erformance

Summary: Android scrolling performance is very poor with this disabled. iOS has some KP with this enabled, so disable it for iOS.

Reviewed By: sahrens

Differential Revision: D13363494

fbshipit-source-id: efab77b5db9676dd0521ae4193465d45ac34dda3
  • Loading branch information
fred2028 authored and facebook-github-bot committed Dec 12, 2018
1 parent dc52cc5 commit 1a499f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Libraries/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
'use strict';

const Platform = require('Platform');
const deepDiffer = require('deepDiffer');
const React = require('React');
const View = require('View');
Expand Down Expand Up @@ -219,6 +220,12 @@ export type Props<ItemT> = RequiredProps<ItemT> &
const defaultProps = {
...VirtualizedList.defaultProps,
numColumns: 1,
/**
* Enabling this prop on Android greatly improves scrolling performance with no known issues.
* The alternative is that scrolling on Android is unusably bad. Enabling it on iOS has a few
* known issues.
*/
removeClippedSubviews: Platform.OS === 'android',
};
export type DefaultProps = typeof defaultProps;

Expand Down
4 changes: 4 additions & 0 deletions Libraries/Lists/__tests__/__snapshots__/FlatList-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ exports[`FlatList renders all the bells and whistles 1`] = `
/>
}
refreshing={false}
removeClippedSubviews={false}
renderItem={[Function]}
scrollEventThrottle={50}
stickyHeaderIndices={Array []}
Expand Down Expand Up @@ -143,6 +144,7 @@ exports[`FlatList renders empty list 1`] = `
onScroll={[Function]}
onScrollBeginDrag={[Function]}
onScrollEndDrag={[Function]}
removeClippedSubviews={false}
renderItem={[Function]}
scrollEventThrottle={50}
stickyHeaderIndices={Array []}
Expand Down Expand Up @@ -171,6 +173,7 @@ exports[`FlatList renders null list 1`] = `
onScroll={[Function]}
onScrollBeginDrag={[Function]}
onScrollEndDrag={[Function]}
removeClippedSubviews={false}
renderItem={[Function]}
scrollEventThrottle={50}
stickyHeaderIndices={Array []}
Expand Down Expand Up @@ -212,6 +215,7 @@ exports[`FlatList renders simple list 1`] = `
onScroll={[Function]}
onScrollBeginDrag={[Function]}
onScrollEndDrag={[Function]}
removeClippedSubviews={false}
renderItem={[Function]}
scrollEventThrottle={50}
stickyHeaderIndices={Array []}
Expand Down

0 comments on commit 1a499f4

Please sign in to comment.