@@ -49,11 +49,7 @@ type HookLogEntry = {
49
49
value : mixed ,
50
50
debugInfo : ReactDebugInfo | null ,
51
51
dispatcherMethodName : string ,
52
- /**
53
- * A list of hook function names that may call this dispatcher method.
54
- * If `null`, we assume that the wrapper name is equal to the dispatcher mthod name.
55
- */
56
- wrapperNames : Array < string > | null ,
52
+ wrapperNames : Array < string > ,
57
53
} ;
58
54
59
55
let hookLog : Array < HookLogEntry > = [ ] ;
@@ -218,7 +214,7 @@ function use<T>(usable: Usable<T>): T {
218
214
debugInfo :
219
215
thenable . _debugInfo === undefined ? null : thenable . _debugInfo ,
220
216
dispatcherMethodName : 'use' ,
221
- wrapperNames : null ,
217
+ wrapperNames : [ 'use' ] ,
222
218
} ) ;
223
219
return fulfilledValue ;
224
220
}
@@ -237,7 +233,7 @@ function use<T>(usable: Usable<T>): T {
237
233
debugInfo :
238
234
thenable . _debugInfo === undefined ? null : thenable . _debugInfo ,
239
235
dispatcherMethodName : 'use' ,
240
- wrapperNames : null ,
236
+ wrapperNames : [ 'use' ] ,
241
237
} );
242
238
throw SuspenseException;
243
239
} else if ( usable . $$typeof === REACT_CONTEXT_TYPE ) {
@@ -251,7 +247,7 @@ function use<T>(usable: Usable<T>): T {
251
247
value,
252
248
debugInfo : null ,
253
249
dispatcherMethodName : 'use' ,
254
- wrapperNames : null ,
250
+ wrapperNames : [ 'use' ] ,
255
251
} ) ;
256
252
257
253
return value ;
@@ -271,7 +267,7 @@ function useContext<T>(context: ReactContext<T>): T {
271
267
value : value ,
272
268
debugInfo : null ,
273
269
dispatcherMethodName : 'useContext' ,
274
- wrapperNames : null ,
270
+ wrapperNames : [ 'useContext' ] ,
275
271
} ) ;
276
272
return value ;
277
273
}
@@ -294,7 +290,7 @@ function useState<S>(
294
290
value : state ,
295
291
debugInfo : null ,
296
292
dispatcherMethodName : 'useState' ,
297
- wrapperNames : null ,
293
+ wrapperNames : [ 'useState' ] ,
298
294
} ) ;
299
295
return [ state , ( action : BasicStateAction < S > ) => { } ] ;
300
296
}
@@ -318,7 +314,7 @@ function useReducer<S, I, A>(
318
314
value : state ,
319
315
debugInfo : null ,
320
316
dispatcherMethodName : 'useReducer' ,
321
- wrapperNames : null ,
317
+ wrapperNames : [ 'useReducer' ] ,
322
318
} ) ;
323
319
return [ state , ( action : A ) => { } ] ;
324
320
}
@@ -333,7 +329,7 @@ function useRef<T>(initialValue: T): {current: T} {
333
329
value : ref . current ,
334
330
debugInfo : null ,
335
331
dispatcherMethodName : 'useRef' ,
336
- wrapperNames : null ,
332
+ wrapperNames : [ 'useRef' ] ,
337
333
} ) ;
338
334
return ref ;
339
335
}
@@ -347,7 +343,7 @@ function useCacheRefresh(): () => void {
347
343
value : hook !== null ? hook . memoizedState : function refresh ( ) { } ,
348
344
debugInfo : null ,
349
345
dispatcherMethodName : 'useCacheRefresh' ,
350
- wrapperNames : null ,
346
+ wrapperNames : [ 'useCacheRefresh' ] ,
351
347
} ) ;
352
348
return ( ) = > { } ;
353
349
}
@@ -364,7 +360,7 @@ function useLayoutEffect(
364
360
value : create ,
365
361
debugInfo : null ,
366
362
dispatcherMethodName : 'useLayoutEffect' ,
367
- wrapperNames : null ,
363
+ wrapperNames : [ 'useLayoutEffect' ] ,
368
364
} ) ;
369
365
}
370
366
@@ -380,7 +376,7 @@ function useInsertionEffect(
380
376
value : create ,
381
377
debugInfo : null ,
382
378
dispatcherMethodName : 'useInsertionEffect' ,
383
- wrapperNames : null ,
379
+ wrapperNames : [ 'useInsertionEffect' ] ,
384
380
} ) ;
385
381
}
386
382
@@ -396,7 +392,7 @@ function useEffect(
396
392
value : create ,
397
393
debugInfo : null ,
398
394
dispatcherMethodName : 'useEffect' ,
399
- wrapperNames : null ,
395
+ wrapperNames : [ 'useEffect' ] ,
400
396
} ) ;
401
397
}
402
398
@@ -421,7 +417,7 @@ function useImperativeHandle<T>(
421
417
value : instance ,
422
418
debugInfo : null ,
423
419
dispatcherMethodName : 'useImperativeHandle' ,
424
- wrapperNames : null ,
420
+ wrapperNames : [ 'useImperativeHandle' ] ,
425
421
} );
426
422
}
427
423
@@ -433,7 +429,7 @@ function useDebugValue(value: any, formatterFn: ?(value: any) => any) {
433
429
value : typeof formatterFn === 'function' ? formatterFn ( value ) : value ,
434
430
debugInfo : null ,
435
431
dispatcherMethodName : 'useDebugValue' ,
436
- wrapperNames : null ,
432
+ wrapperNames : [ 'useDebugValue' ] ,
437
433
} ) ;
438
434
}
439
435
@@ -446,7 +442,7 @@ function useCallback<T>(callback: T, inputs: Array<mixed> | void | null): T {
446
442
value : hook !== null ? hook . memoizedState [ 0 ] : callback ,
447
443
debugInfo : null ,
448
444
dispatcherMethodName : 'useCallback' ,
449
- wrapperNames : null ,
445
+ wrapperNames : [ 'useCallback' ] ,
450
446
} ) ;
451
447
return callback ;
452
448
}
@@ -464,7 +460,7 @@ function useMemo<T>(
464
460
value,
465
461
debugInfo : null ,
466
462
dispatcherMethodName : 'useMemo' ,
467
- wrapperNames : null ,
463
+ wrapperNames : [ 'useMemo' ] ,
468
464
} ) ;
469
465
return value ;
470
466
}
@@ -487,7 +483,7 @@ function useSyncExternalStore<T>(
487
483
value,
488
484
debugInfo : null ,
489
485
dispatcherMethodName : 'useSyncExternalStore' ,
490
- wrapperNames : null ,
486
+ wrapperNames : [ 'useSyncExternalStore' ] ,
491
487
} ) ;
492
488
return value ;
493
489
}
@@ -511,7 +507,7 @@ function useTransition(): [
511
507
value : isPending ,
512
508
debugInfo : null ,
513
509
dispatcherMethodName : 'useTransition' ,
514
- wrapperNames : null ,
510
+ wrapperNames : [ 'useTransition' ] ,
515
511
} ) ;
516
512
return [ isPending , ( ) => { } ] ;
517
513
}
@@ -526,7 +522,7 @@ function useDeferredValue<T>(value: T, initialValue?: T): T {
526
522
value : prevValue ,
527
523
debugInfo : null ,
528
524
dispatcherMethodName : 'useDeferredValue' ,
529
- wrapperNames : null ,
525
+ wrapperNames : [ 'useDeferredValue' ] ,
530
526
} ) ;
531
527
return prevValue ;
532
528
}
@@ -541,7 +537,7 @@ function useId(): string {
541
537
value : id ,
542
538
debugInfo : null ,
543
539
dispatcherMethodName : 'useId' ,
544
- wrapperNames : null ,
540
+ wrapperNames : [ 'useId' ] ,
545
541
} ) ;
546
542
return id ;
547
543
}
@@ -593,7 +589,7 @@ function useOptimistic<S, A>(
593
589
value : state ,
594
590
debugInfo : null ,
595
591
dispatcherMethodName : 'useOptimistic' ,
596
- wrapperNames : null ,
592
+ wrapperNames : [ 'useOptimistic' ] ,
597
593
} ) ;
598
594
return [ state , ( action : A ) => { } ] ;
599
595
}
@@ -654,7 +650,7 @@ function useFormState<S, P>(
654
650
value : value ,
655
651
debugInfo : debugInfo ,
656
652
dispatcherMethodName : 'useFormState' ,
657
- wrapperNames : null ,
653
+ wrapperNames : [ 'useFormState' ] ,
658
654
} );
659
655
660
656
if (error !== null) {
@@ -847,18 +843,8 @@ function findPrimitiveIndex(hookStack: any, hook: HookLogEntry) {
847
843
) {
848
844
i ++ ;
849
845
}
850
- if ( hook . wrapperNames !== null ) {
851
- for ( let j = 0 ; j < hook . wrapperNames . length ; j ++ ) {
852
- const wrapperName = hook . wrapperNames [ j ] ;
853
- if (
854
- i < hookStack . length - 1 &&
855
- isReactWrapper ( hookStack [ i ] . functionName , wrapperName )
856
- ) {
857
- i ++ ;
858
- }
859
- }
860
- } else {
861
- const wrapperName = hook . dispatcherMethodName ;
846
+ for ( let j = 0 ; j < hook . wrapperNames . length ; j ++ ) {
847
+ const wrapperName = hook . wrapperNames [ j ] ;
862
848
if (
863
849
i < hookStack . length - 1 &&
864
850
isReactWrapper ( hookStack [ i ] . functionName , wrapperName )
0 commit comments