throw error when setState's arguments are bad
Cheng Lou committed
Jan 5, 2014 at 18:01 UTC
5b43a2e6d734d7a84b2335c87282eddd7cf3776a
1 file changed
+4
src/core/ReactCompositeComponent.js
+4
@@ -768,6 +768,10 @@ var ReactCompositeComponentMixin = {
768
* @protected
769
*/
770
setState: function(partialState, callback) {
771
+ invariant(
772
+ typeof partialState === 'object' || partialState == null,
773
+ 'setState(...): takes an object of state variables to update.'
774
+ );
775
// Merge with `_pendingState` if it exists, otherwise with existing state.
776
this.replaceState(
777
merge(this._pendingState || this.state, partialState),