question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: Prop with name "is" breaks the className prop on tag

See original GitHub issue

If you add a prop named “is” together with a “className” prop, on a html tag component (e.g. <div is="p" className="text-red">) it “breaks” the markup and render an attribute “classname” instead of “class”.

React & React DOM version: 16.12.0

Steps To Reproduce

  1. Write a simple component that render a html tag
  2. Add a prop named “is” and a “className”
  3. Check the rendered markup

Link to code example: https://codesandbox.io/s/quiet-sun-535rg

Example: <div is="p" className="text-red">I'm not red</div>

The current behavior

Injecting the props as html attrs.

Markup: <div is="p" classname="text-red">I'm not red</div>

The expected behavior

Markup: <div is="p" class="red">I'm red</div>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

1reaction
bvaughncommented, Feb 3, 2020

Sure, if you have ideas for how to improve the docs page send them our way.

This page: https://reactjs.org/docs/web-components.html

Is here: https://github.com/reactjs/reactjs.org/blob/master/content/docs/web-components.md

1reaction
bvaughncommented, Feb 3, 2020

This issue has come up a few times in the past:

Dan’s comment seems inline with ours above: https://github.com/facebook/react/issues/7200#issuecomment-230780250

There’s also been some extensive discussion about the className property on web components here: #4933

Our web component docs suggest using a class attribute in such cases, as confirmed by this comment.

I’m going to close this issue since I think it’s all been discussed before 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

React does not recognize the X prop on a DOM element ...
In my case, I was getting this error when using the IfFirebaseAuthed component from react-firebase.
Read more >
Styling in React: 5 ways to style React apps - LogRocket Blog
Just like XML, JSX tags have a tag name, attributes, and children. The next thing to note is that the properties are separated...
Read more >
Componentizing our React app - Learn web development | MDN
And that's it for this article — we've gone into some depth on how to break up your app nicely into components, and...
Read more >
JSX In Depth - React
Children in JSX. In JSX expressions that contain both an opening tag and a closing tag, the content between those tags is passed...
Read more >
Demystifying styled-components - Josh W Comeau
We apply that class name to our returned HTML element ... and render the Tag variable (our Message component) with a className prop....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found