react / react/react

[DevTools Bug]: Context display does not support HOC name tagging

Open
#33,210 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Component: Developer Tools Status: Unconfirmed Type: Bug
Dominant language
JavaScript
Stars
251k
Forks
51.4k
Avg merge
2d 4h
Merged PRs (30d)
53

Description

Repro steps

We're using HOCs as a way to tag components with certain concerns, this gives us the ability to trim the React Devtools tree to trim down on components that are irrelevant or out of scope (or even specifically in scope).

Image

This works well, except that the name parsing does not apply for named contexts:

const MyOverlayContext = createContext<ContextData | undefined>(undefined);
MyOverlayContext.displayName = 'overlay(MyOverlayContext)'
// shows up as overlay(MyOverlayContext).Provider, instead of MyOverlayContext.Provider [overlay]
() => <MyOverlayContext.Provider />

Image

(We're aware that this isn't how ExoticNamedComponent or HOCs are meant to be used, but they give us the ability to quickly search the tree for certain tags, quickly filter out many browser- or display-like nodes, like <Button />, ` and so on. If you're taking PRs, I would have a look at that, too.)

How often does this bug happen?

Every time

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the named-context example and trace the DevTools context display name parsing; the report does not identify a file or test. Done means a context with displayName 'overlay(MyOverlayContext)' is shown as MyOverlayContext.Provider [overlay], with coverage for the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
devtools, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.