Skip to content

Commit

Permalink
add offscreen state node
Browse files Browse the repository at this point in the history
  • Loading branch information
lunaruan committed Mar 8, 2022
1 parent cb1e7b1 commit 4cd1c2e
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 @@ -727,6 +730,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 @@ -727,6 +730,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 4cd1c2e

Please sign in to comment.