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 Bug]: Newline in component key string will look odd in component tree #28984

Open
JannikGM opened this issue May 3, 2024 · 2 comments

Comments

@JannikGM
Copy link

JannikGM commented May 3, 2024

Website or app

/

Repro steps

Create an element with a key like Foo\n\n\n\nBar\n\n\n\nBaz and it will occupy multiple lines in the component tab.

<div className='App'>
  <h1 key="0-hello\nworld\nfoo\nbar\nbaz">Hello React.</h1>
  <h1 key="1-hello\nworld\nfoo\nbar\nbaz">Hello React.</h1>
</div>

Here's a screenshot:

react-devtools-bug

Background: I've worked on a syntax-highlighter which adds a for each section of text that's colored differently.
As key, I use the index of the element, it's format name and the actual content of the element.
The content can contain whitespaces or blank lines. It can also be very long strings.

How often does this bug happen?

Every time

DevTools package (automated)

No response

DevTools version (automated)

No response

Error message (automated)

No response

Error call stack (automated)

No response

Error component stack (automated)

No response

GitHub query string (automated)

No response

Copy link

github-actions bot commented May 3, 2024

@JannikGM: We're sorry you've seen this error. ❤️

It looks like you forgot to specify a valid URL. (This means that we will not be able to reproduce the problem you're reporting.)

Please help us by providing a link to a CodeSandbox (https://codesandbox.io/s/new), a repository on GitHub, or a minimal code example that reproduces the problem. (Screenshots or videos can also be helpful if they help provide context on how to repro the bug.)

Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve

Issues without repros are automatically closed but we will re-open if you update with repro info.

@github-actions github-actions bot closed this as completed May 3, 2024
@JannikGM JannikGM changed the title [DevTools Bug]: Newline in component key string will look odd in component view [DevTools Bug]: Newline in component key string will look odd in component tree May 3, 2024
@hoxyq hoxyq reopened this May 3, 2024
@hoxyq hoxyq removed Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Resolution: Needs More Information labels May 3, 2024
@hoxyq
Copy link
Contributor

hoxyq commented May 3, 2024

Looks like a good first-time issue for React DevTools: key should be sanitized before displaying in component tree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants