Skip to content
Merged
Prev Previous commit
Next Next commit
Fix uncovered Flow issue
We know nextHydratableInstance doesn't get mutated inside this function, but Flow doesn't so it thinks it may be null.
Help Flow.
  • Loading branch information
gaearon committed May 18, 2018
commit 6037625f016193553fac40e7d66463d359cc67cc
7 changes: 4 additions & 3 deletions packages/react-reconciler/src/ReactFiberHydrationContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import {
return true;
}

function deleteHydratableInstance(returnFiber: Fiber, instance: any /* TODO !!!!!!!!!!!! Instance | TextInstance*/) {
function deleteHydratableInstance(returnFiber: Fiber, instance: Instance | TextInstance) {
if (__DEV__) {
switch (returnFiber.tag) {
case HostRoot:
Expand Down Expand Up @@ -185,11 +185,12 @@ import {
hydrationParentFiber = fiber;
return;
}
const firstAttemptedInstance = nextInstance;
if (!tryHydrate(fiber, nextInstance)) {
// If we can't hydrate this instance let's try the next one.
// We use this as a heuristic. It's based on intuition and not data so it
// might be flawed or unnecessary.
nextInstance = getNextHydratableSibling(nextInstance);
nextInstance = getNextHydratableSibling(firstAttemptedInstance);
if (!nextInstance || !tryHydrate(fiber, nextInstance)) {
// Nothing to hydrate. Make it an insertion.
insertNonHydratedInstance((hydrationParentFiber: any), fiber);
Expand All @@ -203,7 +204,7 @@ import {
// fiber associated with it.
deleteHydratableInstance(
(hydrationParentFiber: any),
nextHydratableInstance,
firstAttemptedInstance,
);
}
hydrationParentFiber = fiber;
Expand Down