Skip to content

Commit 226edea

Browse files
gnoffrickhanlonii
authored andcommitted
[Float] treat props.async in Float consistent with the rest of react-dom (#26760)
Treat async (boolean prop) consistently with Float. Previously float checked if `props.async === true` (or not true) but the rest of react-dom considers anything truthy that isn't a function or symbol as `true`. This PR normalizes the Float behavior.
1 parent fd5e4f8 commit 226edea

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,9 +2417,15 @@ export function getResource(
24172417
return null;
24182418
}
24192419
case 'script': {
2420-
if (typeof pendingProps.src === 'string' && pendingProps.async === true) {
2421-
const scriptProps: ScriptProps = pendingProps;
2422-
const key = getScriptKey(scriptProps.src);
2420+
const async = pendingProps.async;
2421+
const src = pendingProps.src;
2422+
if (
2423+
typeof src === 'string' &&
2424+
async &&
2425+
typeof async !== 'function' &&
2426+
typeof async !== 'symbol'
2427+
) {
2428+
const key = getScriptKey(src);
24232429
const scripts = getResourcesFromRoot(resourceRoot).hoistableScripts;
24242430

24252431
let resource = scripts.get(key);
@@ -3065,16 +3071,20 @@ export function isHostHoistableType(
30653071
}
30663072
}
30673073
case 'script': {
3074+
const isAsync =
3075+
props.async &&
3076+
typeof props.async !== 'function' &&
3077+
typeof props.async !== 'symbol';
30683078
if (
3069-
props.async !== true ||
3079+
!isAsync ||
30703080
props.onLoad ||
30713081
props.onError ||
3072-
typeof props.src !== 'string' ||
3073-
!props.src
3082+
!props.src ||
3083+
typeof props.src !== 'string'
30743084
) {
30753085
if (__DEV__) {
30763086
if (outsideHostContainerContext) {
3077-
if (props.async !== true) {
3087+
if (!isAsync) {
30783088
console.error(
30793089
'Cannot render a sync or defer <script> outside the main document without knowing its order.' +
30803090
' Try adding async="" or moving it into the root <head> tag.',

0 commit comments

Comments
 (0)