update enqueueCallback invariant to more specifically explain what caused error
conorhastings committed
Oct 16, 2015 at 09:20 UTC
20ec78d9f0a8df6c7f4672677f4ece8cd0c8dffd
1 file changed
+8
-4
src/renderers/shared/reconciler/ReactUpdateQueue.js
+8
-4
@@ -109,8 +109,10 @@ var ReactUpdateQueue = {
109
invariant(
110
typeof callback === 'function',
111
'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
112
- '`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
113
- 'isn\'t callable.'
112
+ '`setState`, `replaceState`, or `forceUpdate` with a callback of type ' +
113
+ '%s. A function is expected',
114
+ typeof callback === 'object' && Object.keys(callback).length && Object.keys(callback).length < 20 ?
115
+ typeof callback + ' (keys: ' + Object.keys(callback) + ')' : typeof callback
116
);
117
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);
118
@@ -139,8 +141,10 @@ var ReactUpdateQueue = {
141
invariant(
142
typeof callback === 'function',
143
'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
142
- '`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
143
- 'isn\'t callable.'
144
+ '`setState`, `replaceState`, or `forceUpdate` with a callback of type ' +
145
+ '%s. A function is expected',
146
+ typeof callback === 'object' && Object.keys(callback).length && Object.keys(callback).length < 20 ?
147
+ typeof callback + ' (keys: ' + Object.keys(callback) + ')' : typeof callback
148
);
149
if (internalInstance._pendingCallbacks) {
150
internalInstance._pendingCallbacks.push(callback);