Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devtools: Don't display hook index of useContext #22200

Merged
merged 2 commits into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ function HookView({

let name = hook.name;
if (enableProfilerChangedHookIndices) {
if (!isCustomHook) {
if (hookID !== null) {
name = (
<>
<span className={styles.PrimitiveHookNumber}>{hookID + 1}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@

import * as React from 'react';
import {
createContext,
forwardRef,
Fragment,
memo,
useCallback,
useContext,
useDebugValue,
useEffect,
useState,
Expand Down Expand Up @@ -64,8 +66,13 @@ function useDeepHookF() {
useDebugValue('useDeepHookF');
}

const ContextA = createContext('A');
const ContextB = createContext('B');

function FunctionWithHooks(props: any, ref: React$Ref<any>) {
const [count, updateCount] = useState(0);
// eslint-disable-next-line no-unused-vars
const contextValueA = useContext(ContextA);

// eslint-disable-next-line no-unused-vars
const [_, __] = useState(object);
Expand All @@ -85,6 +92,9 @@ function FunctionWithHooks(props: any, ref: React$Ref<any>) {
// Tests nested custom hooks
useNestedOuterHook();

// eslint-disable-next-line no-unused-vars
const contextValueB = useContext(ContextB);

// Verify deep nesting doesn't break
useDeepHookA();

Expand Down