From 20ec78d9f0a8df6c7f4672677f4ece8cd0c8dffd Mon Sep 17 00:00:00 2001 From: conorhastings Date: Fri, 16 Oct 2015 09:20:13 -0400 Subject: [PATCH] update enqueueCallback invariant to more specifically explain what caused error --- src/renderers/shared/reconciler/ReactUpdateQueue.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/renderers/shared/reconciler/ReactUpdateQueue.js b/src/renderers/shared/reconciler/ReactUpdateQueue.js index 0c5e325a8d35..52bbd6a1198a 100644 --- a/src/renderers/shared/reconciler/ReactUpdateQueue.js +++ b/src/renderers/shared/reconciler/ReactUpdateQueue.js @@ -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);