Skip to content

Commit

Permalink
update enqueueCallback invariant to more specifically explain what ca…
Browse files Browse the repository at this point in the history
…used error
  • Loading branch information
conorhastings committed Oct 16, 2015
1 parent ed7ab7b commit ba24ee5
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/renderers/shared/reconciler/ReactUpdateQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?
'type ' + typeof callback + ' (keys: ' + Object.keys(callback) + ')' : typeof callback;
);
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);

Expand All @@ -136,12 +138,14 @@ var ReactUpdateQueue = {
},

enqueueCallbackInternal: function(internalInstance, callback) {
invariant(
typeof callback === 'function',
'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
'`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
'isn\'t callable.'
);
invariant(
typeof callback === 'function',
'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
'`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 ?
'type ' + typeof callback + ' (keys: ' + Object.keys(callback) + ')' : typeof callback;
);
if (internalInstance._pendingCallbacks) {
internalInstance._pendingCallbacks.push(callback);
} else {
Expand Down

0 comments on commit ba24ee5

Please sign in to comment.