Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 57 additions & 34 deletions backend/attachRendererFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,51 +23,77 @@ 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,
ContextConsumer: 9,
ContextProvider: 10,
CoroutineComponent: -1, // Removed
CoroutineHandlerPhase: -1, // Removed
ForwardRef: 11,
Fragment: 7,
FunctionalComponent: 0,
FunctionalComponentLazy: 1,
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,
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,
ContextConsumer: 12,
ContextProvider: 13,
CoroutineComponent: 7,
CoroutineHandlerPhase: 8,
YieldComponent: 9,
ForwardRef: 14,
Fragment: 10,
FunctionalComponent: 1,
HostComponent: 5,
HostPortal: 4,
HostRoot: 3,
HostText: 6,
IndeterminateComponent: 0,
LazyComponent: -1, // Doesn't exist yet
MemoComponent: -1, // Doesn't exist yet
Mode: 11,
ContextConsumer: 12,
ContextProvider: 13,
ForwardRef: 14,
ForwardRefLazy: -1, // Doesn't exist yet
Profiler: 15,
Placeholder: 16,
SimpleMemoComponent: -1, // Doesn't exist yet
SuspenseComponent: 16,
YieldComponent: 9,
};
}
ReactSymbols = {
Expand All @@ -94,8 +120,9 @@ function getInternalReactConstants(version) {
PerformedWork: 1,
};
// **********************************************************
// End of copy paste.
// End of copied code.
// **********************************************************

return {
ReactTypeOfWork,
ReactSymbols,
Expand All @@ -108,17 +135,14 @@ function attachRendererFiber(hook: Hook, rid: string, renderer: ReactRenderer):
var {PerformedWork} = ReactTypeOfSideEffect;
var {
FunctionalComponent,
FunctionalComponentLazy,
ClassComponent,
ClassComponentLazy,
ContextConsumer,
HostRoot,
HostPortal,
HostComponent,
HostText,
Fragment,
ForwardRef,
ForwardRefLazy,
} = ReactTypeOfWork;
var {
CONCURRENT_MODE_NUMBER,
Expand Down Expand Up @@ -168,11 +192,11 @@ 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:
case ClassComponent:
case ClassComponentLazy:
nodeType = 'Composite';
name = getDisplayName(resolvedType);
publicInstance = fiber.stateNode;
Expand All @@ -197,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 || (
Expand Down