From f62cf8c62052ae780d351090013f7155cf9a868c Mon Sep 17 00:00:00 2001 From: Josh Story Date: Mon, 8 Apr 2024 14:26:58 -0700 Subject: [PATCH] [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. --- .../src/client/ReactFiberConfigDOM.js | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js index ef718516b19fa..91e401b667329 100644 --- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js +++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js @@ -2417,9 +2417,15 @@ export function getResource( return null; } case 'script': { - if (typeof pendingProps.src === 'string' && pendingProps.async === true) { - const scriptProps: ScriptProps = pendingProps; - const key = getScriptKey(scriptProps.src); + const async = pendingProps.async; + const src = pendingProps.src; + if ( + typeof src === 'string' && + async && + typeof async !== 'function' && + typeof async !== 'symbol' + ) { + const key = getScriptKey(src); const scripts = getResourcesFromRoot(resourceRoot).hoistableScripts; let resource = scripts.get(key); @@ -3065,16 +3071,20 @@ export function isHostHoistableType( } } case 'script': { + const isAsync = + props.async && + typeof props.async !== 'function' && + typeof props.async !== 'symbol'; if ( - props.async !== true || + !isAsync || props.onLoad || props.onError || - typeof props.src !== 'string' || - !props.src + !props.src || + typeof props.src !== 'string' ) { if (__DEV__) { if (outsideHostContainerContext) { - if (props.async !== true) { + if (!isAsync) { console.error( 'Cannot render a sync or defer