Skip to content

Commit 274e1cc

Browse files
committed
Remove unnecessary concept of wrapperNames
just look one frame above
1 parent eeece92 commit 274e1cc

File tree

1 file changed

+1
-36
lines changed

1 file changed

+1
-36
lines changed

packages/react-debug-tools/src/ReactDebugHooks.js

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ type HookLogEntry = {
4949
value: mixed,
5050
debugInfo: ReactDebugInfo | null,
5151
dispatcherHookName: string,
52-
wrapperNames: Array<string>,
5352
};
5453

5554
let hookLog: Array<HookLogEntry> = [];
@@ -218,7 +217,6 @@ function use<T>(usable: Usable<T>): T {
218217
debugInfo:
219218
thenable._debugInfo === undefined ? null : thenable._debugInfo,
220219
dispatcherHookName: 'Use',
221-
wrapperNames: ['Use'],
222220
});
223221
return fulfilledValue;
224222
}
@@ -237,7 +235,6 @@ function use<T>(usable: Usable<T>): T {
237235
debugInfo:
238236
thenable._debugInfo === undefined ? null : thenable._debugInfo,
239237
dispatcherHookName: 'Use',
240-
wrapperNames: ['Use'],
241238
});
242239
throw SuspenseException;
243240
} else if (usable.$$typeof === REACT_CONTEXT_TYPE) {
@@ -251,7 +248,6 @@ function use<T>(usable: Usable<T>): T {
251248
value,
252249
debugInfo: null,
253250
dispatcherHookName: 'Use',
254-
wrapperNames: ['Use'],
255251
});
256252

257253
return value;
@@ -271,7 +267,6 @@ function useContext<T>(context: ReactContext<T>): T {
271267
value: value,
272268
debugInfo: null,
273269
dispatcherHookName: 'Context',
274-
wrapperNames: ['Context'],
275270
});
276271
return value;
277272
}
@@ -294,7 +289,6 @@ function useState<S>(
294289
value: state,
295290
debugInfo: null,
296291
dispatcherHookName: 'State',
297-
wrapperNames: ['State'],
298292
});
299293
return [state, (action: BasicStateAction<S>) => {}];
300294
}
@@ -318,7 +312,6 @@ function useReducer<S, I, A>(
318312
value: state,
319313
debugInfo: null,
320314
dispatcherHookName: 'Reducer',
321-
wrapperNames: ['Reducer'],
322315
});
323316
return [state, (action: A) => {}];
324317
}
@@ -333,7 +326,6 @@ function useRef<T>(initialValue: T): {current: T} {
333326
value: ref.current,
334327
debugInfo: null,
335328
dispatcherHookName: 'Ref',
336-
wrapperNames: ['Ref'],
337329
});
338330
return ref;
339331
}
@@ -347,7 +339,6 @@ function useCacheRefresh(): () => void {
347339
value: hook !== null ? hook.memoizedState : function refresh() {},
348340
debugInfo: null,
349341
dispatcherHookName: 'CacheRefresh',
350-
wrapperNames: ['CacheRefresh'],
351342
});
352343
return () => {};
353344
}
@@ -364,7 +355,6 @@ function useLayoutEffect(
364355
value: create,
365356
debugInfo: null,
366357
dispatcherHookName: 'LayoutEffect',
367-
wrapperNames: ['LayoutEffect'],
368358
});
369359
}
370360

@@ -380,7 +370,6 @@ function useInsertionEffect(
380370
value: create,
381371
debugInfo: null,
382372
dispatcherHookName: 'InsertionEffect',
383-
wrapperNames: ['InsertionEffect'],
384373
});
385374
}
386375

@@ -396,7 +385,6 @@ function useEffect(
396385
value: create,
397386
debugInfo: null,
398387
dispatcherHookName: 'Effect',
399-
wrapperNames: ['Effect'],
400388
});
401389
}
402390

@@ -421,7 +409,6 @@ function useImperativeHandle<T>(
421409
value: instance,
422410
debugInfo: null,
423411
dispatcherHookName: 'ImperativeHandle',
424-
wrapperNames: ['ImperativeHandle'],
425412
});
426413
}
427414

@@ -433,7 +420,6 @@ function useDebugValue(value: any, formatterFn: ?(value: any) => any) {
433420
value: typeof formatterFn === 'function' ? formatterFn(value) : value,
434421
debugInfo: null,
435422
dispatcherHookName: 'DebugValue',
436-
wrapperNames: ['DebugValue'],
437423
});
438424
}
439425

@@ -446,7 +432,6 @@ function useCallback<T>(callback: T, inputs: Array<mixed> | void | null): T {
446432
value: hook !== null ? hook.memoizedState[0] : callback,
447433
debugInfo: null,
448434
dispatcherHookName: 'Callback',
449-
wrapperNames: ['Callback'],
450435
});
451436
return callback;
452437
}
@@ -464,7 +449,6 @@ function useMemo<T>(
464449
value,
465450
debugInfo: null,
466451
dispatcherHookName: 'Memo',
467-
wrapperNames: ['Memo'],
468452
});
469453
return value;
470454
}
@@ -487,7 +471,6 @@ function useSyncExternalStore<T>(
487471
value,
488472
debugInfo: null,
489473
dispatcherHookName: 'SyncExternalStore',
490-
wrapperNames: ['SyncExternalStore'],
491474
});
492475
return value;
493476
}
@@ -511,7 +494,6 @@ function useTransition(): [
511494
value: isPending,
512495
debugInfo: null,
513496
dispatcherHookName: 'Transition',
514-
wrapperNames: ['Transition'],
515497
});
516498
return [isPending, () => {}];
517499
}
@@ -526,7 +508,6 @@ function useDeferredValue<T>(value: T, initialValue?: T): T {
526508
value: prevValue,
527509
debugInfo: null,
528510
dispatcherHookName: 'DeferredValue',
529-
wrapperNames: ['DeferredValue'],
530511
});
531512
return prevValue;
532513
}
@@ -541,7 +522,6 @@ function useId(): string {
541522
value: id,
542523
debugInfo: null,
543524
dispatcherHookName: 'Id',
544-
wrapperNames: ['Id'],
545525
});
546526
return id;
547527
}
@@ -593,7 +573,6 @@ function useOptimistic<S, A>(
593573
value: state,
594574
debugInfo: null,
595575
dispatcherHookName: 'Optimistic',
596-
wrapperNames: ['Optimistic'],
597576
});
598577
return [state, (action: A) => {}];
599578
}
@@ -654,7 +633,6 @@ function useFormState<S, P>(
654633
value: value,
655634
debugInfo: debugInfo,
656635
dispatcherHookName: 'FormState',
657-
wrapperNames: ['FormState'],
658636
});
659637

660638
if (error !== null) {
@@ -725,7 +703,6 @@ function useActionState<S, P>(
725703
value: value,
726704
debugInfo: debugInfo,
727705
dispatcherHookName: 'ActionState',
728-
wrapperNames: ['ActionState'],
729706
});
730707

731708
if (error !== null) {
@@ -756,10 +733,6 @@ function useHostTransitionStatus(): TransitionStatus {
756733
value: status,
757734
debugInfo: null,
758735
dispatcherHookName: 'HostTransitionStatus',
759-
wrapperNames: [
760-
// react-dom
761-
'FormStatus',
762-
],
763736
});
764737

765738
return status;
@@ -909,15 +882,7 @@ function findPrimitiveIndex(hookStack: any, hook: HookLogEntry) {
909882
isReactWrapper(hookStack[i].functionName, hook.dispatcherHookName)
910883
) {
911884
i++;
912-
}
913-
for (let j = 0; j < hook.wrapperNames.length; j++) {
914-
const wrapperName = hook.wrapperNames[j];
915-
if (
916-
i < hookStack.length - 1 &&
917-
isReactWrapper(hookStack[i].functionName, wrapperName)
918-
) {
919-
i++;
920-
}
885+
i++;
921886
}
922887
return i;
923888
}

0 commit comments

Comments
 (0)