From efb17dcd842e7c4649e7fbc9cc7a951523c2b61f Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Mon, 22 Oct 2018 11:08:50 -0700 Subject: [PATCH 1/2] Added new tag values for 16.6+ --- backend/attachRendererFiber.js | 88 ++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 25 deletions(-) diff --git a/backend/attachRendererFiber.js b/backend/attachRendererFiber.js index 05b04d128c..b802515762 100644 --- a/backend/attachRendererFiber.js +++ b/backend/attachRendererFiber.js @@ -23,51 +23,86 @@ function getInternalReactConstants(version) { var ReactTypeOfSideEffect; // ********************************************************** - // The section below is copy-pasted from files in React repo. + // The section below is copied from files in React repo. // Keep it in sync, and add version guards if it changes. // ********************************************************** - if (semver.gte(version, '16.4.3-alpha')) { + if (semver.gte(version, '16.6.0-beta.0')) { ReactTypeOfWork = { + ClassComponent: 1, + ClassComponentLazy: -1, // Removed + ContextConsumer: 9, + ContextProvider: 10, + CoroutineComponent: -1, // Removed + CoroutineHandlerPhase: -1, // Removed + ForwardRef: 11, + ForwardRefLazy: -1, // Removed + Fragment: 7, FunctionalComponent: 0, - FunctionalComponentLazy: 1, + FunctionalComponentLazy: -1, // Removed + HostComponent: 5, + HostPortal: 4, + HostRoot: 3, + HostText: 6, + IndeterminateComponent: 2, + LazyComponent: 16, + MemoComponent: 14, + Mode: 8, + Profiler: 12, + SimpleMemoComponent: 15, + SuspenseComponent: 13, + YieldComponent: -1, // Removed + }; + } else if (semver.gte(version, '16.4.3-alpha')) { + ReactTypeOfWork = { ClassComponent: 2, ClassComponentLazy: 3, - IndeterminateComponent: 4, - HostRoot: 5, - HostPortal: 6, - HostComponent: 7, - HostText: 8, - Fragment: 9, - Mode: 10, ContextConsumer: 11, ContextProvider: 12, + CoroutineComponent: -1, // Removed + CoroutineHandlerPhase: -1, // Removed ForwardRef: 13, ForwardRefLazy: 14, + Fragment: 9, + FunctionalComponent: 0, + FunctionalComponentLazy: 1, + HostComponent: 7, + HostPortal: 6, + HostRoot: 5, + HostText: 8, + IndeterminateComponent: 4, + LazyComponent: -1, // Doesn't exist yet + MemoComponent: -1, // Doesn't exist yet + Mode: 10, Profiler: 15, - PlaceholderComponent: 16, + SimpleMemoComponent: -1, // Doesn't exist yet + SuspenseComponent: 16, + YieldComponent: -1, // Removed }; } else { ReactTypeOfWork = { - IndeterminateComponent: 0, - FunctionalComponent: 1, - FunctionalComponentLazy: -1, // Doesn't exist yet ClassComponent: 2, ClassComponentLazy: -1, // Doesn't exist yet - HostRoot: 3, - HostPortal: 4, - HostComponent: 5, - HostText: 6, - CoroutineComponent: 7, - CoroutineHandlerPhase: 8, - YieldComponent: 9, - Fragment: 10, - Mode: 11, ContextConsumer: 12, ContextProvider: 13, + CoroutineComponent: 7, + CoroutineHandlerPhase: 8, ForwardRef: 14, ForwardRefLazy: -1, // Doesn't exist yet + Fragment: 10, + FunctionalComponent: 1, + FunctionalComponentLazy: -1, // Doesn't exist yet + HostComponent: 5, + HostPortal: 4, + HostRoot: 3, + HostText: 6, + IndeterminateComponent: 0, + LazyComponent: -1, // Doesn't exist yet + MemoComponent: -1, // Doesn't exist yet + Mode: 11, Profiler: 15, - Placeholder: 16, + SimpleMemoComponent: -1, // Doesn't exist yet + SuspenseComponent: 16, + YieldComponent: 9, }; } ReactSymbols = { @@ -94,8 +129,9 @@ function getInternalReactConstants(version) { PerformedWork: 1, }; // ********************************************************** - // End of copy paste. + // End of copied code. // ********************************************************** + return { ReactTypeOfWork, ReactSymbols, @@ -168,6 +204,8 @@ function attachRendererFiber(hook: Hook, rid: string, renderer: ReactRenderer): } } + // TODO: Add support for new tags LazyComponent, MemoComponent, and SimpleMemoComponent + switch (fiber.tag) { case FunctionalComponent: case FunctionalComponentLazy: From 37959612e7428305704b10c40e0065ad532c9825 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Mon, 22 Oct 2018 11:23:48 -0700 Subject: [PATCH 2/2] Removed never-released *Lazy tags --- backend/attachRendererFiber.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/backend/attachRendererFiber.js b/backend/attachRendererFiber.js index b802515762..a3534f7c20 100644 --- a/backend/attachRendererFiber.js +++ b/backend/attachRendererFiber.js @@ -29,16 +29,13 @@ function getInternalReactConstants(version) { if (semver.gte(version, '16.6.0-beta.0')) { ReactTypeOfWork = { ClassComponent: 1, - ClassComponentLazy: -1, // Removed ContextConsumer: 9, ContextProvider: 10, CoroutineComponent: -1, // Removed CoroutineHandlerPhase: -1, // Removed ForwardRef: 11, - ForwardRefLazy: -1, // Removed Fragment: 7, FunctionalComponent: 0, - FunctionalComponentLazy: -1, // Removed HostComponent: 5, HostPortal: 4, HostRoot: 3, @@ -55,16 +52,13 @@ function getInternalReactConstants(version) { } else if (semver.gte(version, '16.4.3-alpha')) { ReactTypeOfWork = { ClassComponent: 2, - ClassComponentLazy: 3, ContextConsumer: 11, ContextProvider: 12, CoroutineComponent: -1, // Removed CoroutineHandlerPhase: -1, // Removed ForwardRef: 13, - ForwardRefLazy: 14, Fragment: 9, FunctionalComponent: 0, - FunctionalComponentLazy: 1, HostComponent: 7, HostPortal: 6, HostRoot: 5, @@ -81,16 +75,13 @@ function getInternalReactConstants(version) { } else { ReactTypeOfWork = { ClassComponent: 2, - ClassComponentLazy: -1, // Doesn't exist yet ContextConsumer: 12, ContextProvider: 13, CoroutineComponent: 7, CoroutineHandlerPhase: 8, ForwardRef: 14, - ForwardRefLazy: -1, // Doesn't exist yet Fragment: 10, FunctionalComponent: 1, - FunctionalComponentLazy: -1, // Doesn't exist yet HostComponent: 5, HostPortal: 4, HostRoot: 3, @@ -144,9 +135,7 @@ function attachRendererFiber(hook: Hook, rid: string, renderer: ReactRenderer): var {PerformedWork} = ReactTypeOfSideEffect; var { FunctionalComponent, - FunctionalComponentLazy, ClassComponent, - ClassComponentLazy, ContextConsumer, HostRoot, HostPortal, @@ -154,7 +143,6 @@ function attachRendererFiber(hook: Hook, rid: string, renderer: ReactRenderer): HostText, Fragment, ForwardRef, - ForwardRefLazy, } = ReactTypeOfWork; var { CONCURRENT_MODE_NUMBER, @@ -208,9 +196,7 @@ function attachRendererFiber(hook: Hook, rid: string, renderer: ReactRenderer): switch (fiber.tag) { case FunctionalComponent: - case FunctionalComponentLazy: case ClassComponent: - case ClassComponentLazy: nodeType = 'Composite'; name = getDisplayName(resolvedType); publicInstance = fiber.stateNode; @@ -235,7 +221,6 @@ function attachRendererFiber(hook: Hook, rid: string, renderer: ReactRenderer): children = []; break; case ForwardRef: - case ForwardRefLazy: const functionName = getDisplayName(resolvedType.render, ''); nodeType = 'Special'; name = resolvedType.displayName || (