Skip to content

Commit

Permalink
disable removeClippedSubviews by default
Browse files Browse the repository at this point in the history
Summary:
It's just causing problems (e.g. when combined with transform animations like those used
in some navigators) and hopefully it's not necessary with JS-side windowing. If people need the
perf, they can turn it on themselves.

Should fix facebook#13316 and related issues.

Reviewed By: achen1

Differential Revision: D4884147

fbshipit-source-id: 95c82448581076c0d0b2c80b1cd80cc294898174
  • Loading branch information
sahrens authored and Maxime Aoustin committed Apr 19, 2017
1 parent e25f4fa commit 6835aca
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 23 deletions.
10 changes: 6 additions & 4 deletions Libraries/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ type OptionalProps<ItemT> = {
* Set this true while waiting for new data from a refresh.
*/
refreshing?: ?boolean,
/**
* Note: may have bugs (missing content) in some circumstances - use at your own risk.
*
* This may improve scroll performance for large lists.
*/
removeClippedSubviews?: boolean,
/**
* See `ViewabilityHelper` for flow type and further documentation.
*/
Expand Down Expand Up @@ -273,10 +279,6 @@ type DefaultProps = typeof defaultProps;
* - By default, the list looks for a `key` prop on each item and uses that for the React key.
* Alternatively, you can provide a custom `keyExtractor` prop.
*
* NOTE: `removeClippedSubviews` might not be necessary and may cause bugs. If you see issues with
* content not rendering, e.g when using `LayoutAnimation`, try setting
* `removeClippedSubviews={false}`, and we may change the default in the future after more
* experimentation in production apps.
*/
class FlatList<ItemT> extends React.PureComponent<DefaultProps, Props<ItemT>, void> {
static defaultProps: DefaultProps = defaultProps;
Expand Down
10 changes: 6 additions & 4 deletions Libraries/Lists/SectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ type OptionalProps<SectionT: SectionBase<any>> = {
* Set this true while waiting for new data from a refresh.
*/
refreshing?: ?boolean,
/**
* Note: may have bugs (missing content) in some circumstances - use at your own risk.
*
* This may improve scroll performance for large lists.
*/
removeClippedSubviews?: boolean,
/**
* Rendered at the top of each section. These stick to the top of the `ScrollView` by default on
* iOS. See `stickySectionHeadersEnabled`.
Expand Down Expand Up @@ -217,10 +223,6 @@ type DefaultProps = typeof defaultProps;
* - By default, the list looks for a `key` prop on each item and uses that for the React key.
* Alternatively, you can provide a custom `keyExtractor` prop.
*
* NOTE: `removeClippedSubviews` might not be necessary and may cause bugs. If you see issues with
* content not rendering, e.g when using `LayoutAnimation`, try setting
* `removeClippedSubviews={false}`, and we may change the default in the future after more
* experimentation in production apps.
*/
class SectionList<SectionT: SectionBase<any>>
extends React.PureComponent<DefaultProps, Props<SectionT>, void>
Expand Down
11 changes: 3 additions & 8 deletions Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ type OptionalProps = {
*/
refreshing?: ?boolean,
/**
* A native optimization that removes clipped subviews (those outside the parent) from the view
* hierarchy to offload work from the native rendering system. They are still kept around so no
* memory is saved and state is preserved.
* Note: may have bugs (missing content) in some circumstances - use at your own risk.
*
* This may improve scroll performance for large lists.
*/
removeClippedSubviews?: boolean,
/**
Expand Down Expand Up @@ -167,10 +167,6 @@ type State = {first: number, last: number};
* - By default, the list looks for a `key` prop on each item and uses that for the React key.
* Alternatively, you can provide a custom `keyExtractor` prop.
*
* NOTE: `removeClippedSubviews` might not be necessary and may cause bugs. If you see issues with
* content not rendering, e.g when using `LayoutAnimation`, try setting
* `removeClippedSubviews={false}`, and we may change the default in the future after more
* experimentation in production apps.
*/
class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
props: Props;
Expand Down Expand Up @@ -270,7 +266,6 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
},
maxToRenderPerBatch: 10,
onEndReachedThreshold: 2, // multiples of length
removeClippedSubviews: true,
renderScrollComponent: (props: Props) => {
if (props.onRefresh) {
invariant(
Expand Down
4 changes: 0 additions & 4 deletions Libraries/Lists/__tests__/__snapshots__/FlatList-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ exports[`FlatList renders all the bells and whistles 1`] = `
/>
}
refreshing={false}
removeClippedSubviews={true}
renderItem={[Function]}
renderScrollComponent={[Function]}
scrollEventThrottle={50}
Expand Down Expand Up @@ -150,7 +149,6 @@ exports[`FlatList renders empty list 1`] = `
onScroll={[Function]}
onScrollBeginDrag={[Function]}
onViewableItemsChanged={undefined}
removeClippedSubviews={true}
renderItem={[Function]}
renderScrollComponent={[Function]}
scrollEventThrottle={50}
Expand Down Expand Up @@ -179,7 +177,6 @@ exports[`FlatList renders null list 1`] = `
onScroll={[Function]}
onScrollBeginDrag={[Function]}
onViewableItemsChanged={undefined}
removeClippedSubviews={true}
renderItem={[Function]}
renderScrollComponent={[Function]}
scrollEventThrottle={50}
Expand Down Expand Up @@ -220,7 +217,6 @@ exports[`FlatList renders simple list 1`] = `
onScroll={[Function]}
onScrollBeginDrag={[Function]}
onViewableItemsChanged={undefined}
removeClippedSubviews={true}
renderItem={[Function]}
renderScrollComponent={[Function]}
scrollEventThrottle={50}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ exports[`SectionList rendering empty section headers is fine 1`] = `
onScroll={[Function]}
onScrollBeginDrag={[Function]}
onViewableItemsChanged={undefined}
removeClippedSubviews={true}
renderItem={[Function]}
renderScrollComponent={[Function]}
renderSectionHeader={[Function]}
Expand Down Expand Up @@ -138,7 +137,6 @@ exports[`SectionList renders all the bells and whistles 1`] = `
/>
}
refreshing={false}
removeClippedSubviews={true}
renderItem={[Function]}
renderScrollComponent={[Function]}
renderSectionHeader={[Function]}
Expand Down Expand Up @@ -271,7 +269,6 @@ exports[`SectionList renders empty list 1`] = `
onScroll={[Function]}
onScrollBeginDrag={[Function]}
onViewableItemsChanged={undefined}
removeClippedSubviews={true}
renderItem={[Function]}
renderScrollComponent={[Function]}
scrollEventThrottle={50}
Expand Down

0 comments on commit 6835aca

Please sign in to comment.