Fix string casting and remove Flow suppression comments
Andrew Clark committed
Mar 1, 2017 at 11:08 UTC
5e5bc692302abe678f39479188fdcca855a02086
5 files changed
+6
-12
src/renderers/shared/fiber/ReactChildFiber.js
+2
-4
@@ -117,8 +117,6 @@ function coerceRef(current: Fiber | null, element: ReactElement) {
117
118
function throwOnInvalidObjectType(returnFiber : Fiber, newChild : Object) {
119
if (returnFiber.type !== 'textarea') {
120
- // $FlowFixMe - Intentional cast to string
121
- const childrenString = '' + newChild;
120
let addendum = '';
121
if (__DEV__) {
122
addendum =
@@ -136,9 +134,9 @@ function throwOnInvalidObjectType(returnFiber : Fiber, newChild : Object) {
134
invariant(
135
false,
136
'Objects are not valid as a React child (found: %s).%s',
139
- childrenString === '[object Object]' ?
137
+ Object.prototype.toString.call(newChild) === '[object Object]' ?
138
'object with keys {' + Object.keys(newChild).join(', ') + '}' :
141
- childrenString,
139
+ newChild,
140
addendum
141
);
142
}
src/renderers/shared/fiber/ReactFiberClassComponent.js
+1
-2
@@ -47,8 +47,7 @@ if (__DEV__) {
47
'%s(...): Expected the last optional `callback` argument to be a ' +
48
'function. Instead received: %s.',
49
callerName,
50
- // $FlowFixMe - Intentional cast to string
51
- '' + callback
50
+ callback
51
);
52
};
53
}
src/renderers/shared/fiber/ReactFiberReconciler.js
+1
-2
@@ -168,8 +168,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
168
callback === null || typeof callback === 'function',
169
'render(...): Expected the last optional `callback` argument to be a ' +
170
'function. Instead received: %s.',
171
- // $FlowFixMe - Intentional cast to string
172
- '' + callback
171
+ callback
172
);
173
}
174
addTopLevelUpdate(current, nextState, callback, priorityLevel);
src/renderers/shared/fiber/ReactFiberUpdateQueue.js
+1
-2
@@ -470,8 +470,7 @@ function commitCallbacks(finishedWork : Fiber, queue : UpdateQueue, context : mi
470
typeof callback === 'function',
471
'Invalid argument passed as callback. Expected a function. Instead ' +
472
'received: %s',
473
- // $FlowFixMe - Intentional cast to string
474
- '' + callback
473
+ callback
474
);
475
callback.call(context);
476
}
src/renderers/shared/utils/validateCallback.js
+1
-2
@@ -19,8 +19,7 @@ function validateCallback(callback: ?Function) {
19
!callback || typeof callback === 'function',
20
'Invalid argument passed as callback. Expected a function. Instead ' +
21
'received: %s',
22
- // $FlowFixMe - Intentional cast to string
23
- '' + callback
22
+ callback
23
);
24
}
25