Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Float] treat props.async in Float consistent with the rest of react-dom #26760

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 <script> outside the main document without knowing its order.' +
' Try adding async="" or moving it into the root <head> tag.',
Expand Down