You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Notable changes:
- Bugfix: Selective hydration causing incorrect thenable type passed to DevTools facebook/react#26275
- Bugfix: Crash when a hook is called after `use(promise)` facebook/react#26232
- Support type for ReactDOM.preload() options facebook/react#26239
- Implement preconnect and prefetchDNS methods facebook/react#26237
@@ -4911,9 +4918,11 @@ function createResources() {
4911
4918
return{
4912
4919
// persistent
4913
4920
preloadsMap: newMap(),
4921
+
preconnectsMap: newMap(),
4914
4922
stylesMap: newMap(),
4915
4923
scriptsMap: newMap(),
4916
4924
// cleared on flush
4925
+
preconnects: newSet(),
4917
4926
fontPreloads: newSet(),
4918
4927
// usedImagePreloads: new Set(),
4919
4928
precedences: newMap(),
@@ -4939,6 +4948,98 @@ function getResourceKey(as, href) {
4939
4948
return"["+as+"]"+href;
4940
4949
}
4941
4950
4951
+
functionprefetchDNS(href,options){
4952
+
if(!currentResources){
4953
+
// While we expect that preconnect calls are primarily going to be observed
4954
+
// during render because effects and events don't run on the server it is
4955
+
// still possible that these get called in module scope. This is valid on
4956
+
// the client since there is still a document to interact with but on the
4957
+
// server we need a request to associate the call to. Because of this we
4958
+
// simply return and do not warn.
4959
+
return;
4960
+
}
4961
+
4962
+
varresources=currentResources;
4963
+
4964
+
{
4965
+
if(typeofhref!=='string'||!href){
4966
+
error('ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.',getValueDescriptorExpectingObjectForWarning(href));
error('ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.',getValueDescriptorExpectingEnumForWarning(options));
4970
+
}else{
4971
+
error('ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.',getValueDescriptorExpectingEnumForWarning(options));
4972
+
}
4973
+
}
4974
+
}
4975
+
4976
+
if(typeofhref==='string'&&href){
4977
+
varkey=getResourceKey('prefetchDNS',href);
4978
+
varresource=resources.preconnectsMap.get(key);
4979
+
4980
+
if(!resource){
4981
+
resource={
4982
+
type: 'preconnect',
4983
+
chunks: [],
4984
+
state: NoState,
4985
+
props: null
4986
+
};
4987
+
resources.preconnectsMap.set(key,resource);
4988
+
pushLinkImpl(resource.chunks,{
4989
+
href: href,
4990
+
rel: 'dns-prefetch'
4991
+
});
4992
+
}
4993
+
4994
+
resources.preconnects.add(resource);
4995
+
}
4996
+
}
4997
+
functionpreconnect(href,options){
4998
+
if(!currentResources){
4999
+
// While we expect that preconnect calls are primarily going to be observed
5000
+
// during render because effects and events don't run on the server it is
5001
+
// still possible that these get called in module scope. This is valid on
5002
+
// the client since there is still a document to interact with but on the
5003
+
// server we need a request to associate the call to. Because of this we
5004
+
// simply return and do not warn.
5005
+
return;
5006
+
}
5007
+
5008
+
varresources=currentResources;
5009
+
5010
+
{
5011
+
if(typeofhref!=='string'||!href){
5012
+
error('ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.',getValueDescriptorExpectingObjectForWarning(href));
5013
+
}elseif(options!=null&&typeofoptions!=='object'){
5014
+
error('ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.',getValueDescriptorExpectingEnumForWarning(options));
error('ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.',getValueDescriptorExpectingObjectForWarning(options.crossOrigin));
0 commit comments