Skip to content

Commit 3721cd9

Browse files
committed
Fix string casting and remove Flow suppression comments
1 parent 737dac4 commit 3721cd9

File tree

5 files changed

+6
-12
lines changed

5 files changed

+6
-12
lines changed

src/renderers/shared/fiber/ReactChildFiber.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ function coerceRef(current: Fiber | null, element: ReactElement) {
117117

118118
function throwOnInvalidObjectType(returnFiber : Fiber, newChild : Object) {
119119
if (returnFiber.type !== 'textarea') {
120-
// $FlowFixMe - Intentional cast to string
121-
const childrenString = '' + newChild;
122120
let addendum = '';
123121
if (__DEV__) {
124122
addendum =
@@ -136,9 +134,9 @@ function throwOnInvalidObjectType(returnFiber : Fiber, newChild : Object) {
136134
invariant(
137135
false,
138136
'Objects are not valid as a React child (found: %s).%s',
139-
childrenString === '[object Object]' ?
137+
newChild.toString() === '[object Object]' ?
140138
'object with keys {' + Object.keys(newChild).join(', ') + '}' :
141-
childrenString,
139+
newChild,
142140
addendum
143141
);
144142
}

src/renderers/shared/fiber/ReactFiberClassComponent.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ if (__DEV__) {
4747
'%s(...): Expected the last optional `callback` argument to be a ' +
4848
'function. Instead received: %s.',
4949
callerName,
50-
// $FlowFixMe - Intentional cast to string
51-
'' + callback
50+
callback
5251
);
5352
};
5453
}

src/renderers/shared/fiber/ReactFiberReconciler.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
168168
callback === null || typeof callback === 'function',
169169
'render(...): Expected the last optional `callback` argument to be a ' +
170170
'function. Instead received: %s.',
171-
// $FlowFixMe - Intentional cast to string
172-
'' + callback
171+
callback
173172
);
174173
}
175174
addTopLevelUpdate(current, nextState, callback, priorityLevel);

src/renderers/shared/fiber/ReactFiberUpdateQueue.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,7 @@ function commitCallbacks(finishedWork : Fiber, queue : UpdateQueue, context : mi
470470
typeof callback === 'function',
471471
'Invalid argument passed as callback. Expected a function. Instead ' +
472472
'received: %s',
473-
// $FlowFixMe - Intentional cast to string
474-
'' + callback
473+
callback
475474
);
476475
callback.call(context);
477476
}

src/renderers/shared/utils/validateCallback.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ function validateCallback(callback: ?Function) {
1919
!callback || typeof callback === 'function',
2020
'Invalid argument passed as callback. Expected a function. Instead ' +
2121
'received: %s',
22-
// $FlowFixMe - Intentional cast to string
23-
'' + callback
22+
callback
2423
);
2524
}
2625

0 commit comments

Comments
 (0)