Skip to content

Commit

Permalink
[Re-land] Make prerendering always non-blocking: Add missing feature …
Browse files Browse the repository at this point in the history
…flag checks (facebook#31238)

This is a partial re-land of
facebook#31056. We saw breakages surface
after the original land and had to revert. Now that they've been fixed,
let's try this again. This time we'll split up the commits to give us
more control of testing and rollout internally.

Original PR: facebook#31056
Original Commit:
facebook@2a9fb44
Revert PR: facebook#31080

Commit description:
```
Neglected to wrap some places in the enableSiblingPrerendering flag.
```

Co-authored-by: Andrew Clark <git@andrewclark.io>

DiffTrain build for [13411e4](facebook@13411e4)
  • Loading branch information
AnselK committed Oct 15, 2024
1 parent 0f2a59e commit 5452a01
Show file tree
Hide file tree
Showing 49 changed files with 64,767 additions and 58,855 deletions.
6 changes: 6 additions & 0 deletions compiled/babel-plugin-react-refresh/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @noformat
* @nolint
* @lightSyntaxTransform
* @preventMunge
* @oncall react_core
*/

"use strict";
Expand Down
131 changes: 73 additions & 58 deletions compiled/facebook-www/JSXDEVRuntime-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ __DEV__ &&
)
args[_key2 - 1] = arguments[_key2];
_len2 = format;
_key2 = Error("react-stack-top-frame");
var ReactSharedInternals =
_key2 =
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
null != ReactSharedInternals &&
ReactSharedInternals.getCurrentStack &&
((_key2 = ReactSharedInternals.getCurrentStack(_key2)),
null != _key2 &&
_key2.getCurrentStack &&
((_key2 = _key2.getCurrentStack()),
"" !== _key2 && ((_len2 += "%s"), args.push(_key2)));
args.unshift(_len2);
args.unshift(!1);
Expand Down Expand Up @@ -182,8 +181,14 @@ __DEV__ &&
} catch (x) {
var match = x.stack.trim().match(/\n( *(at )?)/);
prefix = (match && match[1]) || "";
suffix =
-1 < x.stack.indexOf("\n at")
? " (<anonymous>)"
: -1 < x.stack.indexOf("@")
? "@unknown:0:0"
: "";
}
return "\n" + prefix + name;
return "\n" + prefix + name + suffix;
}
function describeNativeComponentFrame(fn, construct) {
if (!fn || reentry) return "";
Expand Down Expand Up @@ -461,7 +466,8 @@ __DEV__ &&
}
function warnIfStringRefCannotBeAutoConverted(config, self) {
var owner;
"string" === typeof config.ref &&
!disableStringRefs &&
"string" === typeof config.ref &&
(owner = getOwner()) &&
self &&
owner.stateNode !== self &&
Expand Down Expand Up @@ -593,13 +599,15 @@ __DEV__ &&
null === type
? (isStaticChildren = "null")
: isArrayImpl(type)
? (isStaticChildren = "array")
: void 0 !== type && type.$$typeof === REACT_ELEMENT_TYPE
? ((isStaticChildren =
"<" + (getComponentNameFromType(type.type) || "Unknown") + " />"),
(children =
" Did you accidentally export a JSX literal instead of a component?"))
: (isStaticChildren = typeof type);
? (isStaticChildren = "array")
: void 0 !== type && type.$$typeof === REACT_ELEMENT_TYPE
? ((isStaticChildren =
"<" +
(getComponentNameFromType(type.type) || "Unknown") +
" />"),
(children =
" Did you accidentally export a JSX literal instead of a component?"))
: (isStaticChildren = typeof type);
error(
"React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",
isStaticChildren,
Expand Down Expand Up @@ -632,22 +640,23 @@ __DEV__ &&
(checkKeyStringCoercion(maybeKey), (children = "" + maybeKey));
hasValidKey(config) &&
(checkKeyStringCoercion(config.key), (children = "" + config.key));
hasValidRef(config) && warnIfStringRefCannotBeAutoConverted(config, self);
hasValidRef(config) &&
(disableStringRefs ||
warnIfStringRefCannotBeAutoConverted(config, self));
if (
(!enableFastJSXWithoutStringRefs &&
(!enableFastJSXWithStringRefs || "ref" in config)) ||
(!enableFastJSXWithoutStringRefs && "ref" in config) ||
"key" in config
) {
maybeKey = {};
for (var propName in config)
"key" !== propName &&
("ref" === propName
? (maybeKey.ref = coerceStringRef(
(disableStringRefs || "ref" !== propName
? (maybeKey[propName] = config[propName])
: (maybeKey.ref = coerceStringRef(
config[propName],
getOwner(),
type
))
: (maybeKey[propName] = config[propName]));
)));
} else maybeKey = config;
if (!disableDefaultPropsExceptForClasses && type && type.defaultProps) {
config = type.defaultProps;
Expand Down Expand Up @@ -753,6 +762,7 @@ __DEV__ &&
return info;
}
function coerceStringRef(mixedRef, owner, type) {
if (disableStringRefs) return mixedRef;
if ("string" !== typeof mixedRef)
if ("number" === typeof mixedRef || "boolean" === typeof mixedRef)
willCoercionThrow(mixedRef) &&
Expand All @@ -771,46 +781,51 @@ __DEV__ &&
return callback;
}
function stringRefAsCallbackRef(stringRef, type, owner, value) {
if (!owner)
throw Error(
"Element ref was specified as a string (" +
stringRef +
") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://react.dev/link/refs-must-have-owner for more information."
);
if (1 !== owner.tag)
throw Error(
"Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://react.dev/link/strict-mode-string-ref"
);
if (
"function" !== typeof type ||
(type.prototype && type.prototype.isReactComponent)
)
(type = getComponentNameFromFiber(owner) || "Component"),
didWarnAboutStringRefs[type] ||
(error(
'Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. We recommend using useRef() or createRef() instead. Learn more about using refs safely here: https://react.dev/link/strict-mode-string-ref',
type,
stringRef
),
(didWarnAboutStringRefs[type] = !0));
owner = owner.stateNode;
if (!owner)
throw Error(
"Missing owner for string ref " +
stringRef +
". This error is likely caused by a bug in React. Please file an issue."
);
owner = owner.refs;
null === value ? delete owner[stringRef] : (owner[stringRef] = value);
if (!disableStringRefs) {
if (!owner)
throw Error(
"Element ref was specified as a string (" +
stringRef +
") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://react.dev/link/refs-must-have-owner for more information."
);
if (1 !== owner.tag)
throw Error(
"Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://react.dev/link/strict-mode-string-ref"
);
if (
"function" !== typeof type ||
(type.prototype && type.prototype.isReactComponent)
)
(type = getComponentNameFromFiber(owner) || "Component"),
didWarnAboutStringRefs[type] ||
(enableLogStringRefsProd &&
enableLogStringRefsProd(type, stringRef),
error(
'Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. We recommend using useRef() or createRef() instead. Learn more about using refs safely here: https://react.dev/link/strict-mode-string-ref',
type,
stringRef
),
(didWarnAboutStringRefs[type] = !0));
owner = owner.stateNode;
if (!owner)
throw Error(
"Missing owner for string ref " +
stringRef +
". This error is likely caused by a bug in React. Please file an issue."
);
owner = owner.refs;
null === value ? delete owner[stringRef] : (owner[stringRef] = value);
}
}
var React = require("react"),
dynamicFeatureFlags = require("ReactFeatureFlags"),
enableDebugTracing = dynamicFeatureFlags.enableDebugTracing,
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing,
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
disableDefaultPropsExceptForClasses =
dynamicFeatureFlags.disableDefaultPropsExceptForClasses,
enableFastJSX = dynamicFeatureFlags.enableFastJSX,
disableStringRefs = dynamicFeatureFlags.disableStringRefs,
enableDebugTracing = dynamicFeatureFlags.enableDebugTracing,
enableLogStringRefsProd = dynamicFeatureFlags.enableLogStringRefsProd,
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing,
renameElementSymbol = dynamicFeatureFlags.renameElementSymbol,
disableLegacyMode = dynamicFeatureFlags.disableLegacyMode;
dynamicFeatureFlags = Symbol.for("react.element");
Expand Down Expand Up @@ -853,6 +868,7 @@ __DEV__ &&
prevGroupEnd;
disabledLog.__reactDisabledLog = !0;
var prefix,
suffix,
reentry = !1;
var componentFrameCache = new (
"function" === typeof WeakMap ? WeakMap : Map
Expand All @@ -861,8 +877,7 @@ __DEV__ &&
specialPropKeyWarningShown;
var didWarnAboutStringRefs = {};
var didWarnAboutElementRef = {};
var enableFastJSXWithStringRefs = enableFastJSX && !0,
enableFastJSXWithoutStringRefs = enableFastJSXWithStringRefs && !1,
var enableFastJSXWithoutStringRefs = disableStringRefs,
didWarnAboutKeySpread = {},
ownerHasKeyUseWarning = {};
exports.Fragment = REACT_FRAGMENT_TYPE;
Expand Down
Loading

0 comments on commit 5452a01

Please sign in to comment.