Skip to content

Commit 49a409f

Browse files
committed
Add todos and proper error message
1 parent 47e301f commit 49a409f

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

packages/react-reconciler/src/ReactFiber.new.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ export function createFiberFromOffscreen(
727727
_pendingMarkers: null,
728728
_retryCache: null,
729729
_transitions: null,
730+
_current: null,
730731
detach: () => detachOffscreenInstance(primaryChildInstance),
731732
};
732733
fiber.stateNode = primaryChildInstance;
@@ -749,6 +750,7 @@ export function createFiberFromLegacyHidden(
749750
_pendingMarkers: null,
750751
_transitions: null,
751752
_retryCache: null,
753+
_current: null,
752754
detach: () => detachOffscreenInstance(instance),
753755
};
754756
fiber.stateNode = instance;

packages/react-reconciler/src/ReactFiberBeginWork.new.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ function updateOffscreenComponent(
683683
nextProps.mode === 'hidden' ||
684684
(enableLegacyHidden &&
685685
nextProps.mode === 'unstable-defer-without-hiding') ||
686+
// TODO: remove read from stateNode.
686687
workInProgress.stateNode._visibility & OffscreenDetached
687688
) {
688689
// Rendering a hidden tree.

packages/react-reconciler/src/ReactFiberCommitWork.new.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2296,7 +2296,9 @@ function getRetryCache(finishedWork) {
22962296
export function detachOffscreenInstance(instance: OffscreenInstance): void {
22972297
const currentOffscreenFiber = instance._current;
22982298
if (currentOffscreenFiber === null) {
2299-
throw new Error('TODO: error message');
2299+
throw new Error(
2300+
'Calling Offscreen.detach before instance handle has been set.',
2301+
);
23002302
}
23012303

23022304
const executionContext = getExecutionContext();
@@ -2697,6 +2699,7 @@ function commitMutationEffectsOnFiber(
26972699
}
26982700

26992701
commitReconciliationEffects(finishedWork);
2702+
// TODO: Add explicit effect flag to set _current.
27002703
finishedWork.stateNode._current = finishedWork;
27012704

27022705
if (flags & Visibility) {

packages/react-reconciler/src/ReactFiberCommitWork.old.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2296,7 +2296,9 @@ function getRetryCache(finishedWork) {
22962296
export function detachOffscreenInstance(instance: OffscreenInstance): void {
22972297
const currentOffscreenFiber = instance._current;
22982298
if (currentOffscreenFiber === null) {
2299-
throw new Error('TODO: error message');
2299+
throw new Error(
2300+
'Calling Offscreen.detach before instance handle has been set.',
2301+
);
23002302
}
23012303

23022304
const executionContext = getExecutionContext();

scripts/error-codes/codes.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,5 +426,6 @@
426426
"438": "An unsupported type was passed to use(): %s",
427427
"439": "We didn't expect to see a forward reference. This is a bug in the React Server.",
428428
"440": "A function wrapped in useEvent can't be called during rendering.",
429-
"441": "An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error."
429+
"441": "An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.",
430+
"442": "Calling Offscreen.detach before instance handle has been set."
430431
}

0 commit comments

Comments
 (0)