@@ -45,6 +45,7 @@ type HookLogEntry = {
45
45
stackError : Error ,
46
46
value : mixed ,
47
47
debugInfo : ReactDebugInfo | null ,
48
+ wrapper : string | null ,
48
49
} ;
49
50
50
51
let hookLog : Array < HookLogEntry > = [ ] ;
@@ -200,6 +201,7 @@ function use<T>(usable: Usable<T>): T {
200
201
value : fulfilledValue ,
201
202
debugInfo :
202
203
thenable . _debugInfo === undefined ? null : thenable . _debugInfo ,
204
+ wrapper : null ,
203
205
} ) ;
204
206
return fulfilledValue ;
205
207
}
@@ -217,6 +219,7 @@ function use<T>(usable: Usable<T>): T {
217
219
value : thenable ,
218
220
debugInfo :
219
221
thenable . _debugInfo === undefined ? null : thenable . _debugInfo ,
222
+ wrapper : null ,
220
223
} );
221
224
throw SuspenseException;
222
225
} else if ( usable . $$typeof === REACT_CONTEXT_TYPE ) {
@@ -229,6 +232,7 @@ function use<T>(usable: Usable<T>): T {
229
232
stackError : new Error ( ) ,
230
233
value,
231
234
debugInfo : null ,
235
+ wrapper : null ,
232
236
} ) ;
233
237
234
238
return value ;
@@ -247,6 +251,7 @@ function useContext<T>(context: ReactContext<T>): T {
247
251
stackError : new Error ( ) ,
248
252
value : value ,
249
253
debugInfo : null ,
254
+ wrapper : null ,
250
255
} ) ;
251
256
return value ;
252
257
}
@@ -268,6 +273,7 @@ function useState<S>(
268
273
stackError : new Error ( ) ,
269
274
value : state ,
270
275
debugInfo : null ,
276
+ wrapper : null ,
271
277
} ) ;
272
278
return [ state , ( action : BasicStateAction < S > ) => { } ] ;
273
279
}
@@ -290,6 +296,7 @@ function useReducer<S, I, A>(
290
296
stackError : new Error ( ) ,
291
297
value : state ,
292
298
debugInfo : null ,
299
+ wrapper : null ,
293
300
} ) ;
294
301
return [ state , ( action : A ) => { } ] ;
295
302
}
@@ -303,6 +310,7 @@ function useRef<T>(initialValue: T): {current: T} {
303
310
stackError : new Error ( ) ,
304
311
value : ref . current ,
305
312
debugInfo : null ,
313
+ wrapper : null ,
306
314
} ) ;
307
315
return ref ;
308
316
}
@@ -315,6 +323,7 @@ function useCacheRefresh(): () => void {
315
323
stackError : new Error ( ) ,
316
324
value : hook !== null ? hook . memoizedState : function refresh ( ) { } ,
317
325
debugInfo : null ,
326
+ wrapper : null ,
318
327
} ) ;
319
328
return ( ) = > { } ;
320
329
}
@@ -330,6 +339,7 @@ function useLayoutEffect(
330
339
stackError : new Error ( ) ,
331
340
value : create ,
332
341
debugInfo : null ,
342
+ wrapper : null ,
333
343
} ) ;
334
344
}
335
345
@@ -344,6 +354,7 @@ function useInsertionEffect(
344
354
stackError : new Error ( ) ,
345
355
value : create ,
346
356
debugInfo : null ,
357
+ wrapper : null ,
347
358
} ) ;
348
359
}
349
360
@@ -358,6 +369,7 @@ function useEffect(
358
369
stackError : new Error ( ) ,
359
370
value : create ,
360
371
debugInfo : null ,
372
+ wrapper : null ,
361
373
} ) ;
362
374
}
363
375
@@ -381,6 +393,7 @@ function useImperativeHandle<T>(
381
393
stackError : new Error ( ) ,
382
394
value : instance ,
383
395
debugInfo : null ,
396
+ wrapper : null ,
384
397
} );
385
398
}
386
399
@@ -391,6 +404,7 @@ function useDebugValue(value: any, formatterFn: ?(value: any) => any) {
391
404
stackError : new Error ( ) ,
392
405
value : typeof formatterFn === 'function' ? formatterFn ( value ) : value ,
393
406
debugInfo : null ,
407
+ wrapper : null ,
394
408
} ) ;
395
409
}
396
410
@@ -402,6 +416,7 @@ function useCallback<T>(callback: T, inputs: Array<mixed> | void | null): T {
402
416
stackError : new Error ( ) ,
403
417
value : hook !== null ? hook . memoizedState [ 0 ] : callback ,
404
418
debugInfo : null ,
419
+ wrapper : null ,
405
420
} ) ;
406
421
return callback ;
407
422
}
@@ -418,6 +433,7 @@ function useMemo<T>(
418
433
stackError : new Error ( ) ,
419
434
value,
420
435
debugInfo : null ,
436
+ wrapper : null ,
421
437
} ) ;
422
438
return value ;
423
439
}
@@ -439,6 +455,7 @@ function useSyncExternalStore<T>(
439
455
stackError : new Error ( ) ,
440
456
value,
441
457
debugInfo : null ,
458
+ wrapper : null ,
442
459
} ) ;
443
460
return value ;
444
461
}
@@ -458,6 +475,7 @@ function useTransition(): [
458
475
stackError : new Error ( ) ,
459
476
value : undefined ,
460
477
debugInfo : null ,
478
+ wrapper : null ,
461
479
} ) ;
462
480
return [ false , callback => { } ] ;
463
481
}
@@ -470,6 +488,7 @@ function useDeferredValue<T>(value: T, initialValue?: T): T {
470
488
stackError : new Error ( ) ,
471
489
value : hook !== null ? hook . memoizedState : value ,
472
490
debugInfo : null ,
491
+ wrapper : null ,
473
492
} ) ;
474
493
return value ;
475
494
}
@@ -483,6 +502,7 @@ function useId(): string {
483
502
stackError : new Error ( ) ,
484
503
value : id ,
485
504
debugInfo : null ,
505
+ wrapper : null ,
486
506
} ) ;
487
507
return id ;
488
508
}
@@ -533,6 +553,7 @@ function useOptimistic<S, A>(
533
553
stackError : new Error ( ) ,
534
554
value : state ,
535
555
debugInfo : null ,
556
+ wrapper : null ,
536
557
} ) ;
537
558
return [ state , ( action : A ) => { } ] ;
538
559
}
@@ -591,6 +612,7 @@ function useFormState<S, P>(
591
612
stackError : stackError ,
592
613
value : value ,
593
614
debugInfo : debugInfo ,
615
+ wrapper : null ,
594
616
} );
595
617
596
618
if (error !== null) {
@@ -618,6 +640,7 @@ function useHostTransitionStatus(): TransitionStatus {
618
640
stackError : new Error ( ) ,
619
641
value : status ,
620
642
debugInfo : null ,
643
+ wrapper : 'FormStatus' ,
621
644
} ) ;
622
645
623
646
return status ;
@@ -788,8 +811,14 @@ function findPrimitiveIndex(hookStack: any, hook: HookLogEntry) {
788
811
}
789
812
if (
790
813
i < hookStack . length - 1 &&
791
- isReactWrapper ( hookStack [ i ] . functionName , hook . primitive )
814
+ isReactWrapper (
815
+ hookStack [ i ] . functionName ,
816
+ hook . wrapper || hook . primitive ,
817
+ )
792
818
) {
819
+ if ( primitiveStack [ i ] . displayName !== null ) {
820
+ primitiveStack [ i ] . displayName = hook . wrapper || hook . primitive ;
821
+ }
793
822
i ++ ;
794
823
}
795
824
return i ;
@@ -798,6 +827,11 @@ function findPrimitiveIndex(hookStack: any, hook: HookLogEntry) {
798
827
return - 1 ;
799
828
}
800
829
830
+ // cache key dispatcher
831
+ // displayName
832
+ // cache key
833
+ // wrapper -> wrappers e.g. `FormStatus`
834
+
801
835
function parseTrimmedStack ( rootStack : any , hook : HookLogEntry ) {
802
836
// Get the stack trace between the primitive hook function and
803
837
// the root function call. I.e. the stack frames of custom hooks.
0 commit comments