@samitouri / QOS-React / commits / 802c820545

Fallback to owner of returnFiber

Won't work if the returnFiber is a fragment. Not sure it matters; warning will just be less descriptive.

Andrew Clark committed Jan 30, 2017 at 11:52 UTC 802c820545b978726388620c35ab4cc35370462b
1 file changed +8 -8
src/renderers/shared/fiber/ReactChildFiber.js
+8 -8
@@ -109,7 +109,7 @@ function coerceRef(current: ?Fiber, element: ReactElement) {
109 return mixedRef;
110 }
111
112 -function throwOnInvalidObjectType(newChild : Object) {
112 +function throwOnInvalidObjectType(returnFiber : Fiber, newChild : Object) {
113 const childrenString = String(newChild);
114 let addendum = '';
115 if (__DEV__) {
@@ -122,9 +122,9 @@ function throwOnInvalidObjectType(newChild : Object) {
122 ' It looks like you\'re using an element created by a different ' +
123 'version of React. Make sure to use only one copy of React.';
124 }
125 - if (ReactCurrentOwner.current) {
126 - const owner : Fiber = (ReactCurrentOwner.current : any);
127 - let name = getComponentName(owner);
125 + const owner = ReactCurrentOwner.owner || returnFiber._debugOwner;
126 + if (owner && typeof owner.tag === 'number') {
127 + const name = getComponentName((owner : any));
128 if (name) {
129 addendum += ' Check the render method of `' + name + '`.';
130 }
@@ -452,7 +452,7 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
452 return created;
453 }
454
455 - throwOnInvalidObjectType(newChild);
455 + throwOnInvalidObjectType(returnFiber, newChild);
456 }
457
458 return null;
@@ -517,7 +517,7 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
517 return updateFragment(returnFiber, oldFiber, newChild, priority);
518 }
519
520 - throwOnInvalidObjectType(newChild);
520 + throwOnInvalidObjectType(returnFiber, newChild);
521 }
522
523 return null;
@@ -574,7 +574,7 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
574 return updateFragment(returnFiber, matchedFiber, newChild, priority);
575 }
576
577 - throwOnInvalidObjectType(newChild);
577 + throwOnInvalidObjectType(returnFiber, newChild);
578 }
579
580 return null;
@@ -1240,7 +1240,7 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
1240 }
1241
1242 if (isObject) {
1243 - throwOnInvalidObjectType(newChild);
1243 + throwOnInvalidObjectType(returnFiber, newChild);
1244 }
1245
1246 if (!disableNewFiberFeatures && typeof newChild === 'undefined') {