diff --git a/Libraries/Experimental/FlatList.js b/Libraries/Experimental/FlatList.js index c605d6b8b30..cf158fe0703 100644 --- a/Libraries/Experimental/FlatList.js +++ b/Libraries/Experimental/FlatList.js @@ -93,7 +93,7 @@ type OptionalProps = { * Multiple columns can only be rendered with horizontal={false} and will zig-zag like a flexWrap * layout. Items should all be the same height - masonry layouts are not supported. */ - numColumns?: number, + numColumns: number, /** * Called once when the scroll position gets within onEndReachedThreshold of the rendered content. */ @@ -145,6 +145,7 @@ type Props = RequiredProps & OptionalProps; // plus props from the underlying im class FlatList extends React.PureComponent { static defaultProps = { keyExtractor: VirtualizedList.defaultProps.keyExtractor, + numColumns: 1, shouldItemUpdate: VirtualizedList.defaultProps.shouldItemUpdate, }; props: Props; @@ -194,13 +195,13 @@ class FlatList extends React.PureComponent { _captureRef = (ref) => { this._listRef = ref; }; _checkProps(props: Props) { - const {getItem, getItemCount, horizontal, legacyImplementation, numColumns, } = props; + const {getItem, getItemCount, horizontal, legacyImplementation, numColumns} = props; invariant(!getItem && !getItemCount, 'FlatList does not support custom data formats.'); if (numColumns > 1) { invariant(!horizontal, 'numColumns does not support horizontal.'); } if (legacyImplementation) { - invariant(!(numColumns > 1), 'Legacy list does not support multiple columns.'); + invariant(numColumns === 1, 'Legacy list does not support multiple columns.'); // Warning: may not have full feature parity and is meant more for debugging and performance // comparison. if (!this._hasWarnedLegacy) { @@ -228,7 +229,7 @@ class FlatList extends React.PureComponent { }; _getItemCount = (data: Array): number => { - return Math.floor(data.length / (this.props.numColumns || 1)); + return Math.floor(data.length / this.props.numColumns); }; _keyExtractor = (items: Item | Array, index: number): string => {