in
.',
);
});
diff --git a/src/renderers/native-cs/ReactNativeCSFiberEntry.js b/src/renderers/native-cs/ReactNativeCSFiberEntry.js
index 72ceb060c70..66c7cdc0adb 100644
--- a/src/renderers/native-cs/ReactNativeCSFiberEntry.js
+++ b/src/renderers/native-cs/ReactNativeCSFiberEntry.js
@@ -194,7 +194,7 @@ const ReactNativeCSFiber: ReactNativeCSType = {
if (!root) {
// TODO (bvaughn): If we decide to keep the wrapper component,
// We could create a wrapper for containerTag as well to reduce special casing.
- root = ReactNativeCSFiberRenderer.createContainer(containerTag);
+ root = ReactNativeCSFiberRenderer.createContainer(containerTag, false);
roots.set(containerTag, root);
}
ReactNativeCSFiberRenderer.updateContainer(element, root, null, callback);
diff --git a/src/renderers/native-rt/ReactNativeRTFiberEntry.js b/src/renderers/native-rt/ReactNativeRTFiberEntry.js
index a367e32336c..684b6a7154c 100644
--- a/src/renderers/native-rt/ReactNativeRTFiberEntry.js
+++ b/src/renderers/native-rt/ReactNativeRTFiberEntry.js
@@ -53,7 +53,7 @@ const ReactNativeRTFiber: ReactNativeRTType = {
if (!root) {
// TODO (bvaughn): If we decide to keep the wrapper component,
// We could create a wrapper for containerTag as well to reduce special casing.
- root = ReactNativeRTFiberRenderer.createContainer(containerTag);
+ root = ReactNativeRTFiberRenderer.createContainer(containerTag, false);
roots.set(containerTag, root);
}
ReactNativeRTFiberRenderer.updateContainer(element, root, null, callback);
diff --git a/src/renderers/native/ReactNativeFiberEntry.js b/src/renderers/native/ReactNativeFiberEntry.js
index b5ba64dbd3f..e149c74a7fa 100644
--- a/src/renderers/native/ReactNativeFiberEntry.js
+++ b/src/renderers/native/ReactNativeFiberEntry.js
@@ -52,7 +52,7 @@ const ReactNativeFiber: ReactNativeType = {
if (!root) {
// TODO (bvaughn): If we decide to keep the wrapper component,
// We could create a wrapper for containerTag as well to reduce special casing.
- root = ReactNativeFiberRenderer.createContainer(containerTag);
+ root = ReactNativeFiberRenderer.createContainer(containerTag, false);
roots.set(containerTag, root);
}
ReactNativeFiberRenderer.updateContainer(element, root, null, callback);
diff --git a/src/renderers/noop/ReactNoopEntry.js b/src/renderers/noop/ReactNoopEntry.js
index a1b7cf099a0..89bfc33c2d7 100644
--- a/src/renderers/noop/ReactNoopEntry.js
+++ b/src/renderers/noop/ReactNoopEntry.js
@@ -269,7 +269,7 @@ var ReactNoop = {
if (!root) {
const container = {rootID: rootID, children: []};
rootContainers.set(rootID, container);
- root = NoopRenderer.createContainer(container);
+ root = NoopRenderer.createContainer(container, false);
roots.set(rootID, root);
}
NoopRenderer.updateContainer(element, root, null, callback);
diff --git a/src/renderers/shared/fiber/ReactFiberBeginWork.js b/src/renderers/shared/fiber/ReactFiberBeginWork.js
index 59499e01ca0..508a41a8622 100644
--- a/src/renderers/shared/fiber/ReactFiberBeginWork.js
+++ b/src/renderers/shared/fiber/ReactFiberBeginWork.js
@@ -338,8 +338,10 @@ module.exports = function(
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
const element = state.element;
+ const root: FiberRoot = workInProgress.stateNode;
if (
(current === null || current.child === null) &&
+ root.hydrate &&
enterHydrationState(workInProgress)
) {
// If we don't have any current children this might be the first pass.
diff --git a/src/renderers/shared/fiber/ReactFiberHydrationContext.js b/src/renderers/shared/fiber/ReactFiberHydrationContext.js
index c1475017dd7..f6024e39c67 100644
--- a/src/renderers/shared/fiber/ReactFiberHydrationContext.js
+++ b/src/renderers/shared/fiber/ReactFiberHydrationContext.js
@@ -77,9 +77,8 @@ module.exports = function(
didNotMatchHydratedTextInstance,
didNotHydrateContainerInstance,
didNotHydrateInstance,
- // TODO: These are currently unused, see below.
- // didNotFindHydratableContainerInstance,
- // didNotFindHydratableContainerTextInstance,
+ didNotFindHydratableContainerInstance,
+ didNotFindHydratableContainerTextInstance,
didNotFindHydratableInstance,
didNotFindHydratableTextInstance,
} = hydration;
@@ -140,25 +139,25 @@ module.exports = function(
fiber.effectTag |= Placement;
if (__DEV__) {
switch (returnFiber.tag) {
- // TODO: Currently we don't warn for insertions into the root because
- // we always insert into the root in the non-hydrating case. We just
- // delete the existing content. Reenable this once we have a better
- // strategy for determining if we're hydrating or not.
- // case HostRoot: {
- // const parentContainer = returnFiber.stateNode.containerInfo;
- // switch (fiber.tag) {
- // case HostComponent:
- // const type = fiber.type;
- // const props = fiber.pendingProps;
- // didNotFindHydratableContainerInstance(parentContainer, type, props);
- // break;
- // case HostText:
- // const text = fiber.pendingProps;
- // didNotFindHydratableContainerTextInstance(parentContainer, text);
- // break;
- // }
- // break;
- // }
+ case HostRoot: {
+ const parentContainer = returnFiber.stateNode.containerInfo;
+ switch (fiber.tag) {
+ case HostComponent:
+ const type = fiber.type;
+ const props = fiber.pendingProps;
+ didNotFindHydratableContainerInstance(
+ parentContainer,
+ type,
+ props,
+ );
+ break;
+ case HostText:
+ const text = fiber.pendingProps;
+ didNotFindHydratableContainerTextInstance(parentContainer, text);
+ break;
+ }
+ break;
+ }
case HostComponent: {
const parentType = returnFiber.type;
const parentProps = returnFiber.memoizedProps;
diff --git a/src/renderers/shared/fiber/ReactFiberReconciler.js b/src/renderers/shared/fiber/ReactFiberReconciler.js
index e0972a0314a..7f6a7c3017c 100644
--- a/src/renderers/shared/fiber/ReactFiberReconciler.js
+++ b/src/renderers/shared/fiber/ReactFiberReconciler.js
@@ -219,7 +219,7 @@ type HydrationHostConfig = {
};
export type Reconciler = {
- createContainer(containerInfo: C): OpaqueRoot,
+ createContainer(containerInfo: C, hydrate: boolean): OpaqueRoot,
updateContainer(
element: ReactNodeList,
container: OpaqueRoot,
@@ -335,8 +335,8 @@ module.exports = function(
}
return {
- createContainer(containerInfo: C): OpaqueRoot {
- return createFiberRoot(containerInfo);
+ createContainer(containerInfo: C, hydrate: boolean): OpaqueRoot {
+ return createFiberRoot(containerInfo, hydrate);
},
updateContainer(
diff --git a/src/renderers/shared/fiber/ReactFiberRoot.js b/src/renderers/shared/fiber/ReactFiberRoot.js
index f78205d2bca..419e842e08b 100644
--- a/src/renderers/shared/fiber/ReactFiberRoot.js
+++ b/src/renderers/shared/fiber/ReactFiberRoot.js
@@ -26,9 +26,14 @@ export type FiberRoot = {
// Top context object, used by renderSubtreeIntoContainer
context: Object | null,
pendingContext: Object | null,
+ // Determines if we should attempt to hydrate on the initial mount
+ +hydrate: boolean,
};
-exports.createFiberRoot = function(containerInfo: any): FiberRoot {
+exports.createFiberRoot = function(
+ containerInfo: any,
+ hydrate: boolean,
+): FiberRoot {
// Cyclic construction. This cheats the type system right now because
// stateNode is any.
const uninitializedFiber = createHostRootFiber();
@@ -39,6 +44,7 @@ exports.createFiberRoot = function(containerInfo: any): FiberRoot {
nextScheduledRoot: null,
context: null,
pendingContext: null,
+ hydrate,
};
uninitializedFiber.stateNode = root;
return root;
diff --git a/src/renderers/testing/ReactTestRendererFiberEntry.js b/src/renderers/testing/ReactTestRendererFiberEntry.js
index 1b0253f5125..79144a1449a 100644
--- a/src/renderers/testing/ReactTestRendererFiberEntry.js
+++ b/src/renderers/testing/ReactTestRendererFiberEntry.js
@@ -574,7 +574,7 @@ var ReactTestRendererFiber = {
createNodeMock,
tag: 'CONTAINER',
};
- var root: FiberRoot | null = TestRenderer.createContainer(container);
+ var root: FiberRoot | null = TestRenderer.createContainer(container, false);
invariant(root != null, 'something went wrong');
TestRenderer.updateContainer(element, root, null, null);