From 7b634a70fb3bacba3c4b7146cd63399f57130b98 Mon Sep 17 00:00:00 2001 From: Luna Ruan Date: Tue, 15 Mar 2022 16:28:50 -0400 Subject: [PATCH] add offscreen state node (#24026) Add state node on Offscreen fibers with id (in preparation for transition tracing) --- packages/react-reconciler/src/ReactFiber.new.js | 7 ++++++- packages/react-reconciler/src/ReactFiber.old.js | 7 ++++++- .../react-reconciler/src/ReactFiberOffscreenComponent.js | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiber.new.js b/packages/react-reconciler/src/ReactFiber.new.js index 1509d2201117d..b28f1fee9b0e8 100644 --- a/packages/react-reconciler/src/ReactFiber.new.js +++ b/packages/react-reconciler/src/ReactFiber.new.js @@ -15,7 +15,10 @@ import type {WorkTag} from './ReactWorkTags'; import type {TypeOfMode} from './ReactTypeOfMode'; import type {Lanes} from './ReactFiberLane.new'; import type {SuspenseInstance, Props} from './ReactFiberHostConfig'; -import type {OffscreenProps} from './ReactFiberOffscreenComponent'; +import type { + OffscreenProps, + OffscreenInstance, +} from './ReactFiberOffscreenComponent'; import { createRootStrictEffectsByDefault, @@ -735,6 +738,8 @@ export function createFiberFromOffscreen( const fiber = createFiber(OffscreenComponent, pendingProps, key, mode); fiber.elementType = REACT_OFFSCREEN_TYPE; fiber.lanes = lanes; + const primaryChildInstance: OffscreenInstance = {}; + fiber.stateNode = primaryChildInstance; return fiber; } diff --git a/packages/react-reconciler/src/ReactFiber.old.js b/packages/react-reconciler/src/ReactFiber.old.js index ba9f5132b45ca..5c4301977a3ea 100644 --- a/packages/react-reconciler/src/ReactFiber.old.js +++ b/packages/react-reconciler/src/ReactFiber.old.js @@ -15,7 +15,10 @@ import type {WorkTag} from './ReactWorkTags'; import type {TypeOfMode} from './ReactTypeOfMode'; import type {Lanes} from './ReactFiberLane.old'; import type {SuspenseInstance, Props} from './ReactFiberHostConfig'; -import type {OffscreenProps} from './ReactFiberOffscreenComponent'; +import type { + OffscreenProps, + OffscreenInstance, +} from './ReactFiberOffscreenComponent'; import { createRootStrictEffectsByDefault, @@ -735,6 +738,8 @@ export function createFiberFromOffscreen( const fiber = createFiber(OffscreenComponent, pendingProps, key, mode); fiber.elementType = REACT_OFFSCREEN_TYPE; fiber.lanes = lanes; + const primaryChildInstance: OffscreenInstance = {}; + fiber.stateNode = primaryChildInstance; return fiber; } diff --git a/packages/react-reconciler/src/ReactFiberOffscreenComponent.js b/packages/react-reconciler/src/ReactFiberOffscreenComponent.js index 87e1eaa244540..2d0fea0657a84 100644 --- a/packages/react-reconciler/src/ReactFiberOffscreenComponent.js +++ b/packages/react-reconciler/src/ReactFiberOffscreenComponent.js @@ -31,3 +31,5 @@ export type OffscreenState = {| baseLanes: Lanes, cachePool: SpawnedCachePool | null, |}; + +export type OffscreenInstance = {};