@@ -55,13 +55,24 @@ function printWarning(level, format, args) {
5555 }
5656}
5757
58- var ReactVersion = '18.3.0-experimental-14898b6a9-20240318' ;
59-
58+ var ReactVersion = '18.3.0-experimental-c3048aab4-20240326' ;
59+
60+ function noop ( ) { }
61+
62+ var DefaultDispatcher = {
63+ prefetchDNS : noop ,
64+ preconnect : noop ,
65+ preload : noop ,
66+ preloadModule : noop ,
67+ preinitScript : noop ,
68+ preinitStyle : noop ,
69+ preinitModuleScript : noop
70+ } ;
6071var Internals = {
6172 usingClientEntryPoint : false ,
6273 Events : null ,
63- Dispatcher : {
64- current : null
74+ ReactDOMCurrentDispatcher : {
75+ current : DefaultDispatcher
6576 }
6677} ;
6778
@@ -84,7 +95,7 @@ function getCrossOriginStringAs(as, input) {
8495 return undefined ;
8596}
8697
87- var Dispatcher = Internals . Dispatcher ;
98+ var ReactDOMCurrentDispatcher = Internals . ReactDOMCurrentDispatcher ;
8899function prefetchDNS ( href ) {
89100 {
90101 if ( typeof href !== 'string' || ! href ) {
@@ -100,10 +111,8 @@ function prefetchDNS(href) {
100111 }
101112 }
102113
103- var dispatcher = Dispatcher . current ;
104-
105- if ( dispatcher && typeof href === 'string' ) {
106- dispatcher . prefetchDNS ( href ) ;
114+ if ( typeof href === 'string' ) {
115+ ReactDOMCurrentDispatcher . current . prefetchDNS ( href ) ;
107116 } // We don't error because preconnect needs to be resilient to being called in a variety of scopes
108117 // and the runtime may not be capable of responding. The function is optimistic and not critical
109118 // so we favor silent bailout over warning or erroring.
@@ -120,11 +129,9 @@ function preconnect(href, options) {
120129 }
121130 }
122131
123- var dispatcher = Dispatcher . current ;
124-
125- if ( dispatcher && typeof href === 'string' ) {
132+ if ( typeof href === 'string' ) {
126133 var crossOrigin = options ? getCrossOriginString ( options . crossOrigin ) : null ;
127- dispatcher . preconnect ( href , crossOrigin ) ;
134+ ReactDOMCurrentDispatcher . current . preconnect ( href , crossOrigin ) ;
128135 } // We don't error because preconnect needs to be resilient to being called in a variety of scopes
129136 // and the runtime may not be capable of responding. The function is optimistic and not critical
130137 // so we favor silent bailout over warning or erroring.
@@ -149,13 +156,11 @@ function preload(href, options) {
149156 }
150157 }
151158
152- var dispatcher = Dispatcher . current ;
153-
154- if ( dispatcher && typeof href === 'string' && // We check existence because we cannot enforce this function is actually called with the stated type
159+ if ( typeof href === 'string' && // We check existence because we cannot enforce this function is actually called with the stated type
155160 typeof options === 'object' && options !== null && typeof options . as === 'string' ) {
156161 var as = options . as ;
157162 var crossOrigin = getCrossOriginStringAs ( as , options . crossOrigin ) ;
158- dispatcher . preload ( href , as , {
163+ ReactDOMCurrentDispatcher . current . preload ( href , as , {
159164 crossOrigin : crossOrigin ,
160165 integrity : typeof options . integrity === 'string' ? options . integrity : undefined ,
161166 nonce : typeof options . nonce === 'string' ? options . nonce : undefined ,
@@ -189,18 +194,16 @@ function preloadModule(href, options) {
189194 }
190195 }
191196
192- var dispatcher = Dispatcher . current ;
193-
194- if ( dispatcher && typeof href === 'string' ) {
197+ if ( typeof href === 'string' ) {
195198 if ( options ) {
196199 var crossOrigin = getCrossOriginStringAs ( options . as , options . crossOrigin ) ;
197- dispatcher . preloadModule ( href , {
200+ ReactDOMCurrentDispatcher . current . preloadModule ( href , {
198201 as : typeof options . as === 'string' && options . as !== 'script' ? options . as : undefined ,
199202 crossOrigin : crossOrigin ,
200203 integrity : typeof options . integrity === 'string' ? options . integrity : undefined
201204 } ) ;
202205 } else {
203- dispatcher . preloadModule ( href ) ;
206+ ReactDOMCurrentDispatcher . current . preloadModule ( href ) ;
204207 }
205208 } // We don't error because preload needs to be resilient to being called in a variety of scopes
206209 // and the runtime may not be capable of responding. The function is optimistic and not critical
@@ -218,22 +221,20 @@ function preinit(href, options) {
218221 }
219222 }
220223
221- var dispatcher = Dispatcher . current ;
222-
223- if ( dispatcher && typeof href === 'string' && options && typeof options . as === 'string' ) {
224+ if ( typeof href === 'string' && options && typeof options . as === 'string' ) {
224225 var as = options . as ;
225226 var crossOrigin = getCrossOriginStringAs ( as , options . crossOrigin ) ;
226227 var integrity = typeof options . integrity === 'string' ? options . integrity : undefined ;
227228 var fetchPriority = typeof options . fetchPriority === 'string' ? options . fetchPriority : undefined ;
228229
229230 if ( as === 'style' ) {
230- dispatcher . preinitStyle ( href , typeof options . precedence === 'string' ? options . precedence : undefined , {
231+ ReactDOMCurrentDispatcher . current . preinitStyle ( href , typeof options . precedence === 'string' ? options . precedence : undefined , {
231232 crossOrigin : crossOrigin ,
232233 integrity : integrity ,
233234 fetchPriority : fetchPriority
234235 } ) ;
235236 } else if ( as === 'script' ) {
236- dispatcher . preinitScript ( href , {
237+ ReactDOMCurrentDispatcher . current . preinitScript ( href , {
237238 crossOrigin : crossOrigin ,
238239 integrity : integrity ,
239240 fetchPriority : fetchPriority ,
@@ -281,20 +282,18 @@ function preinitModule(href, options) {
281282 }
282283 }
283284
284- var dispatcher = Dispatcher . current ;
285-
286- if ( dispatcher && typeof href === 'string' ) {
285+ if ( typeof href === 'string' ) {
287286 if ( typeof options === 'object' && options !== null ) {
288287 if ( options . as == null || options . as === 'script' ) {
289288 var crossOrigin = getCrossOriginStringAs ( options . as , options . crossOrigin ) ;
290- dispatcher . preinitModuleScript ( href , {
289+ ReactDOMCurrentDispatcher . current . preinitModuleScript ( href , {
291290 crossOrigin : crossOrigin ,
292291 integrity : typeof options . integrity === 'string' ? options . integrity : undefined ,
293292 nonce : typeof options . nonce === 'string' ? options . nonce : undefined
294293 } ) ;
295294 }
296295 } else if ( options == null ) {
297- dispatcher . preinitModuleScript ( href ) ;
296+ ReactDOMCurrentDispatcher . current . preinitModuleScript ( href ) ;
298297 }
299298 } // We don't error because preinit needs to be resilient to being called in a variety of scopes
300299 // and the runtime may not be capable of responding. The function is optimistic and not critical
@@ -319,7 +318,7 @@ function resolveDispatcher() {
319318
320319 {
321320 if ( dispatcher === null ) {
322- error ( 'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' + ' one of the following reasons:\n' + '1. You might have mismatching versions of React and the renderer (such as React DOM)\n' + '2. You might be breaking the Rules of Hooks\n' + '3. You might have more than one copy of React in the same app\n' + 'See https://reactjs.org /link/invalid-hook-call for tips about how to debug and fix this problem.' ) ;
321+ error ( 'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' + ' one of the following reasons:\n' + '1. You might have mismatching versions of React and the renderer (such as React DOM)\n' + '2. You might be breaking the Rules of Hooks\n' + '3. You might have more than one copy of React in the same app\n' + 'See https://react.dev /link/invalid-hook-call for tips about how to debug and fix this problem.' ) ;
323322 }
324323 } // Will result in a null access error if accessed outside render phase. We
325324 // intentionally don't throw our own error because this is in a hot path.
0 commit comments