From 46d6766a53f6fa7550ad4dd34bcb97549e716ef7 Mon Sep 17 00:00:00 2001 From: Spencer Ahrens Date: Tue, 21 Mar 2017 22:19:13 -0700 Subject: [PATCH] useful error when switching numColumns on the fly Reviewed By: blairvanderhoof, bvaughn Differential Revision: D4742842 fbshipit-source-id: a11a088194ead02cc11eb6ccd9ce6d6f75ead3a3 --- Libraries/CustomComponents/Lists/FlatList.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Libraries/CustomComponents/Lists/FlatList.js b/Libraries/CustomComponents/Lists/FlatList.js index 2f7bd153638..77ca170845c 100644 --- a/Libraries/CustomComponents/Lists/FlatList.js +++ b/Libraries/CustomComponents/Lists/FlatList.js @@ -242,6 +242,11 @@ class FlatList extends React.PureComponent, vo } componentWillReceiveProps(nextProps: Props) { + invariant( + nextProps.numColumns === this.props.numColumns, + 'Changing numColumns on the fly is not supported. Change the key prop on FlatList when ' + + 'changing the number of columns to force a fresh render of the component.' + ); this._checkProps(nextProps); }