Skip to content

Commit e980d83

Browse files
MoOxfacebook-github-bot
authored andcommittedApr 4, 2019
- VirtualizedSectionList/SectionList: replace enableVirtualization prop annotation by correct underlying disableVirtualisation of VirtualizedList (#24312)
Summary: It seems (I used git history to confirm) that FlatList/VirtualizedList have ([since the begining](https://github.com/facebook/react-native/blame/c13f5d48cfe3e7c0f6c6d0b745b50a089d6993ef/Libraries/Lists/VirtualizedList.js#L79)) a `disableVirtualization` prop. SectionList ([since it's begining](https://github.com/facebook/react-native/blame/abe737fe746406533798f9670e8e243cb18d5634/Libraries/Lists/VirtualizedSectionList.js#L98)) have a `enableVirtualization` prop, but since SectionList is VirtualizedSectionList which use VirtualizedList, this prop probably never did something. This fix just rename the prop properly so it can have an effect on the underlying VirtualizedList when you use a SectionList. Since props are spread it's kind of working already, but the flow annotation are wrong (so it tells you it won't work/ you can't use it) which sucks. (NB: I am doing this since I was trying to use a SectionList with react-native-web & server side rendering to get the all list, you can laugh). [General] [Fixed] - VirtualizedSectionList/SectionList: replace enableVirtualization prop annotation by correct underlying disableVirtualisation of VirtualizedList Pull Request resolved: #24312 Differential Revision: D14779449 Pulled By: cpojer fbshipit-source-id: e51e1d639d2bb265b5b286786010d01ffd9d90e0
1 parent 8e37585 commit e980d83

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed
 

‎Libraries/Lists/VirtualizedList.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ type OptionalProps = {
7676
* unmounts react instances that are outside of the render window. You should only need to disable
7777
* this for debugging purposes.
7878
*/
79-
disableVirtualization: boolean,
79+
disableVirtualization?: ?boolean,
8080
/**
8181
* A marker property for telling the list to re-render (since it implements `PureComponent`). If
8282
* any of your `renderItem`, Header, Footer, etc. functions depend on anything outside of the
@@ -705,7 +705,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
705705
};
706706

707707
_isVirtualizationDisabled(): boolean {
708-
return this.props.disableVirtualization;
708+
return this.props.disableVirtualization || false;
709709
}
710710

711711
_isNestedWithSameOrientation(): boolean {

‎Libraries/Lists/VirtualizedSectionList.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ type OptionalProps<SectionT: SectionBase> = {
9191
*/
9292
ItemSeparatorComponent?: ?React.ComponentType<any>,
9393
/**
94-
* Warning: Virtualization can drastically improve memory consumption for long lists, but trashes
95-
* the state of items when they scroll out of the render window, so make sure all relavent data is
96-
* stored outside of the recursive `renderItem` instance tree.
94+
* DEPRECATED: Virtualization provides significant performance and memory optimizations, but fully
95+
* unmounts react instances that are outside of the render window. You should only need to disable
96+
* this for debugging purposes.
9797
*/
98-
enableVirtualization?: ?boolean,
98+
disableVirtualization?: ?boolean,
9999
keyExtractor: (item: Item, index: number) => string,
100100
onEndReached?: ?({distanceFromEnd: number}) => void,
101101
/**

‎RNTester/js/SectionListExample.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class SectionListExample extends React.PureComponent<{}, $FlowFixMeState> {
149149
)}
150150
debug={this.state.debug}
151151
inverted={this.state.inverted}
152-
enableVirtualization={this.state.virtualized}
152+
disableVirtualization={!this.state.virtualized}
153153
onRefresh={() => Alert.alert('onRefresh: nothing to refresh :P')}
154154
onScroll={this._scrollSinkY}
155155
onViewableItemsChanged={this._onViewableItemsChanged}

0 commit comments

Comments
 (0)
Please sign in to comment.