Skip to content

Commit 46d6766

Browse files
sahrensfacebook-github-bot
authored andcommitted
useful error when switching numColumns on the fly
Reviewed By: blairvanderhoof, bvaughn Differential Revision: D4742842 fbshipit-source-id: a11a088194ead02cc11eb6ccd9ce6d6f75ead3a3
1 parent 1531f5f commit 46d6766

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Libraries/CustomComponents/Lists/FlatList.js

+5
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ class FlatList<ItemT> extends React.PureComponent<DefaultProps, Props<ItemT>, vo
242242
}
243243

244244
componentWillReceiveProps(nextProps: Props<ItemT>) {
245+
invariant(
246+
nextProps.numColumns === this.props.numColumns,
247+
'Changing numColumns on the fly is not supported. Change the key prop on FlatList when ' +
248+
'changing the number of columns to force a fresh render of the component.'
249+
);
245250
this._checkProps(nextProps);
246251
}
247252

0 commit comments

Comments
 (0)