Bug: Prop with name "is" breaks the className prop on tag
See original GitHub issueIf 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
- Write a simple component that render a html tag
- Add a prop named “is” and a “className”
- 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:
- Created 4 years ago
- Reactions:2
- Comments:5
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
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: #4933Our 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 😄