mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
better error message for mergeHelpers and setState
This commit is contained in:
@@ -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),
|
||||
|
||||
11
src/vendor/core/mergeHelpers.js
vendored
11
src/vendor/core/mergeHelpers.js
vendored
@@ -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
|
||||
);
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user