Skip to content

Commit

Permalink
Fix suspense replaying forward refs (#26535)
Browse files Browse the repository at this point in the history
Continuation of #26420

Fixes #26385 and
#26419

---------

Co-authored-by: eps1lon <silbermann.sebastian@gmail.com>
Co-authored-by: Andrew Clark <git@andrewclark.io>

DiffTrain build for [7329ea8](7329ea8)
  • Loading branch information
acdlite committed Apr 2, 2023
1 parent e1d88e6 commit 54201b8
Show file tree
Hide file tree
Showing 18 changed files with 967 additions and 791 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0ae348018d5b3a3f1ccdd92de85d9cc581b2b98d
7329ea81c154d40800e30104be40f050e8c2af3e
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-www-modern-01f5e12b";
var ReactVersion = "18.3.0-www-modern-be9a0998";

// ATTENTION
// When adding new symbols to this file,
Expand Down
43 changes: 28 additions & 15 deletions compiled/facebook-www/ReactART-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
return self;
}

var ReactVersion = "18.3.0-www-classic-69b188ab";
var ReactVersion = "18.3.0-www-classic-ec4b0889";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -13731,18 +13731,12 @@ function replayFunctionComponent(
workInProgress,
nextProps,
Component,
secondArg,
renderLanes
) {
// This function is used to replay a component that previously suspended,
// after its data resolves. It's a simplified version of
// updateFunctionComponent that reuses the hooks from the previous attempt.
var context;

{
var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
context = getMaskedContext(workInProgress, unmaskedContext);
}

prepareToReadContext(workInProgress, renderLanes);

if (enableSchedulingProfiler) {
Expand All @@ -13754,7 +13748,7 @@ function replayFunctionComponent(
workInProgress,
Component,
nextProps,
context
secondArg
);

if (enableSchedulingProfiler) {
Expand Down Expand Up @@ -25396,8 +25390,8 @@ function replaySuspendedUnitOfWork(unitOfWork) {
}
// eslint-disable-next-line no-fallthrough

case FunctionComponent:
case ForwardRef: {
case SimpleMemoComponent:
case FunctionComponent: {
// Resolve `defaultProps`. This logic is copied from `beginWork`.
// TODO: Consider moving this switch statement into that module. Also,
// could maybe use this as an opportunity to say `use` doesn't work with
Expand All @@ -25408,24 +25402,43 @@ function replaySuspendedUnitOfWork(unitOfWork) {
unitOfWork.elementType === Component
? unresolvedProps
: resolveDefaultProps(Component, unresolvedProps);
var context;

{
var unmaskedContext = getUnmaskedContext(unitOfWork, Component, true);
context = getMaskedContext(unitOfWork, unmaskedContext);
}

next = replayFunctionComponent(
current,
unitOfWork,
resolvedProps,
Component,
context,
workInProgressRootRenderLanes
);
break;
}

case SimpleMemoComponent: {
var _Component = unitOfWork.type;
var nextProps = unitOfWork.pendingProps;
case ForwardRef: {
// Resolve `defaultProps`. This logic is copied from `beginWork`.
// TODO: Consider moving this switch statement into that module. Also,
// could maybe use this as an opportunity to say `use` doesn't work with
// `defaultProps` :)
var _Component = unitOfWork.type.render;
var _unresolvedProps = unitOfWork.pendingProps;

var _resolvedProps =
unitOfWork.elementType === _Component
? _unresolvedProps
: resolveDefaultProps(_Component, _unresolvedProps);

next = replayFunctionComponent(
current,
unitOfWork,
nextProps,
_resolvedProps,
_Component,
unitOfWork.ref,
workInProgressRootRenderLanes
);
break;
Expand Down
33 changes: 23 additions & 10 deletions compiled/facebook-www/ReactART-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
return self;
}

var ReactVersion = "18.3.0-www-modern-e02e9428";
var ReactVersion = "18.3.0-www-modern-ae3f1831";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -13448,13 +13448,12 @@ function replayFunctionComponent(
workInProgress,
nextProps,
Component,
secondArg,
renderLanes
) {
// This function is used to replay a component that previously suspended,
// after its data resolves. It's a simplified version of
// updateFunctionComponent that reuses the hooks from the previous attempt.
var context;

prepareToReadContext(workInProgress, renderLanes);

if (enableSchedulingProfiler) {
Expand All @@ -13466,7 +13465,7 @@ function replayFunctionComponent(
workInProgress,
Component,
nextProps,
context
secondArg
);

if (enableSchedulingProfiler) {
Expand Down Expand Up @@ -25056,8 +25055,8 @@ function replaySuspendedUnitOfWork(unitOfWork) {
}
// eslint-disable-next-line no-fallthrough

case FunctionComponent:
case ForwardRef: {
case SimpleMemoComponent:
case FunctionComponent: {
// Resolve `defaultProps`. This logic is copied from `beginWork`.
// TODO: Consider moving this switch statement into that module. Also,
// could maybe use this as an opportunity to say `use` doesn't work with
Expand All @@ -25068,24 +25067,38 @@ function replaySuspendedUnitOfWork(unitOfWork) {
unitOfWork.elementType === Component
? unresolvedProps
: resolveDefaultProps(Component, unresolvedProps);
var context;

next = replayFunctionComponent(
current,
unitOfWork,
resolvedProps,
Component,
context,
workInProgressRootRenderLanes
);
break;
}

case SimpleMemoComponent: {
var _Component = unitOfWork.type;
var nextProps = unitOfWork.pendingProps;
case ForwardRef: {
// Resolve `defaultProps`. This logic is copied from `beginWork`.
// TODO: Consider moving this switch statement into that module. Also,
// could maybe use this as an opportunity to say `use` doesn't work with
// `defaultProps` :)
var _Component = unitOfWork.type.render;
var _unresolvedProps = unitOfWork.pendingProps;

var _resolvedProps =
unitOfWork.elementType === _Component
? _unresolvedProps
: resolveDefaultProps(_Component, _unresolvedProps);

next = replayFunctionComponent(
current,
unitOfWork,
nextProps,
_resolvedProps,
_Component,
unitOfWork.ref,
workInProgressRootRenderLanes
);
break;
Expand Down
57 changes: 33 additions & 24 deletions compiled/facebook-www/ReactART-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3887,18 +3887,15 @@ function replayFunctionComponent(
workInProgress,
nextProps,
Component,
secondArg,
renderLanes
) {
var context = isContextProvider(Component)
? previousContext
: contextStackCursor$1.current;
context = getMaskedContext(workInProgress, context);
prepareToReadContext(workInProgress, renderLanes);
nextProps = renderWithHooksAgain(
workInProgress,
Component,
nextProps,
context
secondArg
);
finishRenderingHooks(current);
if (null !== current && !didReceiveUpdate)
Expand Down Expand Up @@ -8549,28 +8546,40 @@ function replaySuspendedUnitOfWork(unitOfWork) {
switch (unitOfWork.tag) {
case 2:
unitOfWork.tag = 0;
case 15:
case 0:
case 11:
var Component = unitOfWork.type,
unresolvedProps = unitOfWork.pendingProps;
unresolvedProps =
unitOfWork.elementType === Component
? unresolvedProps
: resolveDefaultProps(Component, unresolvedProps);
var context = isContextProvider(Component)
? previousContext
: contextStackCursor$1.current;
context = getMaskedContext(unitOfWork, context);
current = replayFunctionComponent(
current,
unitOfWork,
unresolvedProps,
Component,
context,
workInProgressRootRenderLanes
);
break;
case 15:
case 11:
Component = unitOfWork.type.render;
unresolvedProps = unitOfWork.pendingProps;
unresolvedProps =
unitOfWork.elementType === Component
? unresolvedProps
: resolveDefaultProps(Component, unresolvedProps);
current = replayFunctionComponent(
current,
unitOfWork,
unitOfWork.pendingProps,
unitOfWork.type,
unresolvedProps,
Component,
unitOfWork.ref,
workInProgressRootRenderLanes
);
break;
Expand Down Expand Up @@ -10053,19 +10062,19 @@ var slice = Array.prototype.slice,
};
return Text;
})(React.Component),
devToolsConfig$jscomp$inline_1168 = {
devToolsConfig$jscomp$inline_1170 = {
findFiberByHostInstance: function () {
return null;
},
bundleType: 0,
version: "18.3.0-www-classic-d70758c5",
version: "18.3.0-www-classic-3b2e6228",
rendererPackageName: "react-art"
};
var internals$jscomp$inline_1342 = {
bundleType: devToolsConfig$jscomp$inline_1168.bundleType,
version: devToolsConfig$jscomp$inline_1168.version,
rendererPackageName: devToolsConfig$jscomp$inline_1168.rendererPackageName,
rendererConfig: devToolsConfig$jscomp$inline_1168.rendererConfig,
var internals$jscomp$inline_1344 = {
bundleType: devToolsConfig$jscomp$inline_1170.bundleType,
version: devToolsConfig$jscomp$inline_1170.version,
rendererPackageName: devToolsConfig$jscomp$inline_1170.rendererPackageName,
rendererConfig: devToolsConfig$jscomp$inline_1170.rendererConfig,
overrideHookState: null,
overrideHookStateDeletePath: null,
overrideHookStateRenamePath: null,
Expand All @@ -10082,26 +10091,26 @@ var internals$jscomp$inline_1342 = {
return null === fiber ? null : fiber.stateNode;
},
findFiberByHostInstance:
devToolsConfig$jscomp$inline_1168.findFiberByHostInstance ||
devToolsConfig$jscomp$inline_1170.findFiberByHostInstance ||
emptyFindFiberByHostInstance,
findHostInstancesForRefresh: null,
scheduleRefresh: null,
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-classic-d70758c5"
reconcilerVersion: "18.3.0-www-classic-3b2e6228"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1343 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
var hook$jscomp$inline_1345 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
if (
!hook$jscomp$inline_1343.isDisabled &&
hook$jscomp$inline_1343.supportsFiber
!hook$jscomp$inline_1345.isDisabled &&
hook$jscomp$inline_1345.supportsFiber
)
try {
(rendererID = hook$jscomp$inline_1343.inject(
internals$jscomp$inline_1342
(rendererID = hook$jscomp$inline_1345.inject(
internals$jscomp$inline_1344
)),
(injectedHook = hook$jscomp$inline_1343);
(injectedHook = hook$jscomp$inline_1345);
} catch (err) {}
}
var Path = Mode$1.Path;
Expand Down
Loading

0 comments on commit 54201b8

Please sign in to comment.