update enqueueCallback invariant to more specifically explain what caused error

This commit is contained in:
conorhastings
2015-10-16 09:20:13 -04:00
parent ed7ab7b94a
commit 20ec78d9f0
@@ -109,8 +109,10 @@ var ReactUpdateQueue = {
invariant(
typeof callback === 'function',
'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
'`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
'isn\'t callable.'
'`setState`, `replaceState`, or `forceUpdate` with a callback of type ' +
'%s. A function is expected',
typeof callback === 'object' && Object.keys(callback).length && Object.keys(callback).length < 20 ?
typeof callback + ' (keys: ' + Object.keys(callback) + ')' : typeof callback
);
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);
@@ -139,8 +141,10 @@ var ReactUpdateQueue = {
invariant(
typeof callback === 'function',
'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
'`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
'isn\'t callable.'
'`setState`, `replaceState`, or `forceUpdate` with a callback of type ' +
'%s. A function is expected',
typeof callback === 'object' && Object.keys(callback).length && Object.keys(callback).length < 20 ?
typeof callback + ' (keys: ' + Object.keys(callback) + ')' : typeof callback
);
if (internalInstance._pendingCallbacks) {
internalInstance._pendingCallbacks.push(callback);