Skip to content

Commit 685d65b

Browse files
committed
No duck typing on the root
The root is always a host container.
1 parent bc5dfd5 commit 685d65b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/renderers/shared/fiber/ReactFiberScheduler.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ var {
3838
Deletion,
3939
} = require('ReactTypeOfSideEffect');
4040

41+
var {
42+
HostContainer,
43+
} = require('ReactTypeOfWork');
44+
4145
var timeHeuristicForUnitOfWork = 1;
4246

4347
module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
@@ -399,14 +403,14 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
399403
fiber.alternate.pendingWorkPriority = priorityLevel;
400404
}
401405
}
402-
// Duck type root
403-
if (fiber.stateNode && fiber.stateNode.containerInfo) {
404-
const root : FiberRoot = (fiber.stateNode : any);
405-
scheduleDeferredWork(root, priorityLevel);
406-
return;
407-
}
408406
if (!fiber.return) {
409-
throw new Error('No root!');
407+
if (fiber.tag === HostContainer) {
408+
const root : FiberRoot = (fiber.stateNode : any);
409+
scheduleDeferredWork(root, priorityLevel);
410+
return;
411+
} else {
412+
throw new Error('Invalid root');
413+
}
410414
}
411415
fiber = fiber.return;
412416
}

0 commit comments

Comments
 (0)