From bf7a1a0d5e3562994f5f7679be90c3c760d5982b Mon Sep 17 00:00:00 2001 From: eps1lon Date: Mon, 15 Apr 2024 22:57:24 +0200 Subject: [PATCH] Remove unnecessary concept of `wrapperNames` just look one frame above --- .../react-debug-tools/src/ReactDebugHooks.js | 37 +------------------ packages/shared/ReactVersion.js | 16 +------- 2 files changed, 2 insertions(+), 51 deletions(-) diff --git a/packages/react-debug-tools/src/ReactDebugHooks.js b/packages/react-debug-tools/src/ReactDebugHooks.js index a2e2f6626cb91..a5be893f1d7a5 100644 --- a/packages/react-debug-tools/src/ReactDebugHooks.js +++ b/packages/react-debug-tools/src/ReactDebugHooks.js @@ -49,7 +49,6 @@ type HookLogEntry = { value: mixed, debugInfo: ReactDebugInfo | null, dispatcherHookName: string, - wrapperNames: Array, }; let hookLog: Array = []; @@ -218,7 +217,6 @@ function use(usable: Usable): T { debugInfo: thenable._debugInfo === undefined ? null : thenable._debugInfo, dispatcherHookName: 'Use', - wrapperNames: ['Use'], }); return fulfilledValue; } @@ -237,7 +235,6 @@ function use(usable: Usable): T { debugInfo: thenable._debugInfo === undefined ? null : thenable._debugInfo, dispatcherHookName: 'Use', - wrapperNames: ['Use'], }); throw SuspenseException; } else if (usable.$$typeof === REACT_CONTEXT_TYPE) { @@ -251,7 +248,6 @@ function use(usable: Usable): T { value, debugInfo: null, dispatcherHookName: 'Use', - wrapperNames: ['Use'], }); return value; @@ -271,7 +267,6 @@ function useContext(context: ReactContext): T { value: value, debugInfo: null, dispatcherHookName: 'Context', - wrapperNames: ['Context'], }); return value; } @@ -294,7 +289,6 @@ function useState( value: state, debugInfo: null, dispatcherHookName: 'State', - wrapperNames: ['State'], }); return [state, (action: BasicStateAction) => {}]; } @@ -318,7 +312,6 @@ function useReducer( value: state, debugInfo: null, dispatcherHookName: 'Reducer', - wrapperNames: ['Reducer'], }); return [state, (action: A) => {}]; } @@ -333,7 +326,6 @@ function useRef(initialValue: T): {current: T} { value: ref.current, debugInfo: null, dispatcherHookName: 'Ref', - wrapperNames: ['Ref'], }); return ref; } @@ -347,7 +339,6 @@ function useCacheRefresh(): () => void { value: hook !== null ? hook.memoizedState : function refresh() {}, debugInfo: null, dispatcherHookName: 'CacheRefresh', - wrapperNames: ['CacheRefresh'], }); return () => {}; } @@ -364,7 +355,6 @@ function useLayoutEffect( value: create, debugInfo: null, dispatcherHookName: 'LayoutEffect', - wrapperNames: ['LayoutEffect'], }); } @@ -380,7 +370,6 @@ function useInsertionEffect( value: create, debugInfo: null, dispatcherHookName: 'InsertionEffect', - wrapperNames: ['InsertionEffect'], }); } @@ -396,7 +385,6 @@ function useEffect( value: create, debugInfo: null, dispatcherHookName: 'Effect', - wrapperNames: ['Effect'], }); } @@ -421,7 +409,6 @@ function useImperativeHandle( value: instance, debugInfo: null, dispatcherHookName: 'ImperativeHandle', - wrapperNames: ['ImperativeHandle'], }); } @@ -433,7 +420,6 @@ function useDebugValue(value: any, formatterFn: ?(value: any) => any) { value: typeof formatterFn === 'function' ? formatterFn(value) : value, debugInfo: null, dispatcherHookName: 'DebugValue', - wrapperNames: ['DebugValue'], }); } @@ -446,7 +432,6 @@ function useCallback(callback: T, inputs: Array | void | null): T { value: hook !== null ? hook.memoizedState[0] : callback, debugInfo: null, dispatcherHookName: 'Callback', - wrapperNames: ['Callback'], }); return callback; } @@ -464,7 +449,6 @@ function useMemo( value, debugInfo: null, dispatcherHookName: 'Memo', - wrapperNames: ['Memo'], }); return value; } @@ -487,7 +471,6 @@ function useSyncExternalStore( value, debugInfo: null, dispatcherHookName: 'SyncExternalStore', - wrapperNames: ['SyncExternalStore'], }); return value; } @@ -511,7 +494,6 @@ function useTransition(): [ value: isPending, debugInfo: null, dispatcherHookName: 'Transition', - wrapperNames: ['Transition'], }); return [isPending, () => {}]; } @@ -526,7 +508,6 @@ function useDeferredValue(value: T, initialValue?: T): T { value: prevValue, debugInfo: null, dispatcherHookName: 'DeferredValue', - wrapperNames: ['DeferredValue'], }); return prevValue; } @@ -541,7 +522,6 @@ function useId(): string { value: id, debugInfo: null, dispatcherHookName: 'Id', - wrapperNames: ['Id'], }); return id; } @@ -593,7 +573,6 @@ function useOptimistic( value: state, debugInfo: null, dispatcherHookName: 'Optimistic', - wrapperNames: ['Optimistic'], }); return [state, (action: A) => {}]; } @@ -654,7 +633,6 @@ function useFormState( value: value, debugInfo: debugInfo, dispatcherHookName: 'FormState', - wrapperNames: ['FormState'], }); if (error !== null) { @@ -725,7 +703,6 @@ function useActionState( value: value, debugInfo: debugInfo, dispatcherHookName: 'ActionState', - wrapperNames: ['ActionState'], }); if (error !== null) { @@ -756,10 +733,6 @@ function useHostTransitionStatus(): TransitionStatus { value: status, debugInfo: null, dispatcherHookName: 'HostTransitionStatus', - wrapperNames: [ - // react-dom - 'FormStatus', - ], }); return status; @@ -909,15 +882,7 @@ function findPrimitiveIndex(hookStack: any, hook: HookLogEntry) { isReactWrapper(hookStack[i].functionName, hook.dispatcherHookName) ) { i++; - } - for (let j = 0; j < hook.wrapperNames.length; j++) { - const wrapperName = hook.wrapperNames[j]; - if ( - i < hookStack.length - 1 && - isReactWrapper(hookStack[i].functionName, wrapperName) - ) { - i++; - } + i++; } return i; } diff --git a/packages/shared/ReactVersion.js b/packages/shared/ReactVersion.js index 13dd40e747e0d..446e5880c0c97 100644 --- a/packages/shared/ReactVersion.js +++ b/packages/shared/ReactVersion.js @@ -1,15 +1 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// TODO: this is special because it gets imported during build. -// -// It exists as a placeholder so that DevTools can support work tag changes between releases. -// When we next publish a release, update the matching TODO in backend/renderer.js -// TODO: This module is used both by the release scripts and to expose a version -// at runtime. We should instead inject the version number as part of the build -// process, and use the ReactVersions.js module as the single source of truth. -export default '19.0.0'; +export default '19.0.0-PLACEHOLDER';