diff --git a/src/core/ReactCompositeComponent.js b/src/core/ReactCompositeComponent.js index cf31bf09d9..6211867711 100644 --- a/src/core/ReactCompositeComponent.js +++ b/src/core/ReactCompositeComponent.js @@ -772,6 +772,14 @@ var ReactCompositeComponentMixin = { typeof partialState === 'object' || partialState == null, 'setState(...): takes an object of state variables to update.' ); + if (__DEV__){ + if (partialState == null) { + console.warn( + 'setState(...): You passed an undefined or null state object; ' + + 'instead, use forceUpdate().' + ); + } + } // Merge with `_pendingState` if it exists, otherwise with existing state. this.replaceState( merge(this._pendingState || this.state, partialState), diff --git a/src/vendor/core/mergeHelpers.js b/src/vendor/core/mergeHelpers.js index d25cfcff87..1047bc46fc 100644 --- a/src/vendor/core/mergeHelpers.js +++ b/src/vendor/core/mergeHelpers.js @@ -66,9 +66,9 @@ var mergeHelpers = { checkMergeArrayArgs: function(one, two) { invariant( Array.isArray(one) && Array.isArray(two), - 'Critical assumptions about the merge functions have been violated. ' + - 'This is the fault of the merge functions themselves, not necessarily ' + - 'the callers.' + 'Tried to merge arrays, instead got %s and %s.', + one, + two ); }, @@ -87,9 +87,8 @@ var mergeHelpers = { checkMergeObjectArg: function(arg) { invariant( !isTerminal(arg) && !Array.isArray(arg), - 'Critical assumptions about the merge functions have been violated. ' + - 'This is the fault of the merge functions themselves, not necessarily ' + - 'the callers.' + 'Tried to merge an object, instead got %s.', + arg ); },