GeezerVison is showing github.com — [Float] treat `props.async` in Float consistent with the rest of reac… · react/react@f62cf8c
File tree
Expand file treeCollapse file tree
Open diff view settings
packages/react-dom-bindings/src/client
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js +17-7Lines changed: 17 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2417,9 +2417,15 @@ export function getResource( |
2417 | 2417 | return null; |
2418 | 2418 | } |
2419 | 2419 | 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); |
2423 | 2429 | const scripts = getResourcesFromRoot(resourceRoot).hoistableScripts; |
2424 | 2430 |
|
2425 | 2431 | let resource = scripts.get(key); |
@@ -3065,16 +3071,20 @@ export function isHostHoistableType( |
3065 | 3071 | } |
3066 | 3072 | } |
3067 | 3073 | case 'script': { |
| 3074 | + const isAsync = |
| 3075 | + props.async && |
| 3076 | + typeof props.async !== 'function' && |
| 3077 | + typeof props.async !== 'symbol'; |
3068 | 3078 | if ( |
3069 | | - props.async !== true || |
| 3079 | + !isAsync || |
3070 | 3080 | props.onLoad || |
3071 | 3081 | props.onError || |
3072 | | - typeof props.src !== 'string' || |
3073 | | - !props.src |
| 3082 | + !props.src || |
| 3083 | + typeof props.src !== 'string' |
3074 | 3084 | ) { |
3075 | 3085 | if (__DEV__) { |
3076 | 3086 | if (outsideHostContainerContext) { |
3077 | | - if (props.async !== true) { |
| 3087 | + if (!isAsync) { |
3078 | 3088 | console.error( |
3079 | 3089 | 'Cannot render a sync or defer <script> outside the main document without knowing its order.' + |
3080 | 3090 | ' Try adding async="" or moving it into the root <head> tag.', |
|