Skip to content

Commit eac399b

Browse files
Xinbo Wangfacebook-github-bot
authored andcommitted
Add flexWrap warning
Reviewed By: sahrens Differential Revision: D5117970 fbshipit-source-id: 11b542bd6cd7b1ab22ba8f6822d471df94fa7da2
1 parent 35338e9 commit eac399b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Libraries/Lists/VirtualizedList.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ const ScrollView = require('ScrollView');
2020
const View = require('View');
2121
const ViewabilityHelper = require('ViewabilityHelper');
2222

23+
const flattenStyle = require('flattenStyle');
2324
const infoLog = require('infoLog');
2425
const invariant = require('fbjs/lib/invariant');
26+
const warning = require('fbjs/lib/warning');
2527

2628
const {computeWindowedRenderLimits} = require('VirtualizeUtils');
2729

@@ -409,6 +411,15 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
409411
};
410412

411413
render() {
414+
if (__DEV__) {
415+
const flatStyles = flattenStyle(this.props.contentContainerStyle);
416+
warning(
417+
flatStyles == null || flatStyles.flexWrap !== 'wrap',
418+
'`flexWrap: `wrap`` is not supported with the `VirtualizedList` components.' +
419+
'Consider using `numColumns` with `FlatList` instead.',
420+
);
421+
}
422+
412423
const {ListEmptyComponent, ListFooterComponent, ListHeaderComponent} = this.props;
413424
const {data, disableVirtualization, horizontal} = this.props;
414425
const cells = [];

RNTester/js/FlatListExample.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212
'use strict';
1313

14+
const Alert = require('Alert');
1415
const React = require('react');
1516
const ReactNative = require('react-native');
1617
const {
@@ -160,7 +161,7 @@ class FlatListExample extends React.PureComponent {
160161
data: state.data.concat(genItemData(100, state.data.length)),
161162
}));
162163
};
163-
_onRefresh = () => alert('onRefresh: nothing to refresh :P');
164+
_onRefresh = () => Alert.alert('onRefresh: nothing to refresh :P');
164165
_renderItemComponent = ({item, separators}) => {
165166
return (
166167
<ItemComponent

0 commit comments

Comments
 (0)