Skip to content

Commit

Permalink
add offscreen state node (facebook#24026)
Browse files Browse the repository at this point in the history
Add state node on Offscreen fibers with id (in preparation for transition tracing)
  • Loading branch information
lunaruan authored and zhengjitf committed Apr 15, 2022
1 parent 0fad2ea commit 7b634a7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/react-reconciler/src/ReactFiber.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}

Expand Down
7 changes: 6 additions & 1 deletion packages/react-reconciler/src/ReactFiber.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions packages/react-reconciler/src/ReactFiberOffscreenComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ export type OffscreenState = {|
baseLanes: Lanes,
cachePool: SpawnedCachePool | null,
|};

export type OffscreenInstance = {};

0 comments on commit 7b634a7

Please sign in to comment.