React does not recognize the XX prop on a DOM element
See original GitHub issueDescription
React console error whenever passing props to a goober styled component:
React does not recognize the XX prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase XX instead. If you accidentally passed it from a parent component, remove it from the DOM element.
When happening Passing through some props to a goober styled component (see codesandbox)
Possible solution?
See transient props
from styled-components
Codesandbox See the console logs https://codesandbox.io/s/vigorous-gates-0o2ge?file=/src/App.js
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:10 (7 by maintainers)
Top Results From Across the Web
React does not recognize the `xxx` prop on a DOM element
React does not recognize the `setEditMode` prop on a DOM element. If you intentionally want it to appear in the DOM as a...
Read more >Warning:react does not recognize the XXX prop on a DOM ...
This is a warning that react does not recognize non-standard attribute on DOM elements, and react removes these nonstandard attribute in the ...
Read more >[DatePicker] Show Warning: React does not recognize the xxx ...
Expected Behavior. I think it is a problem that occurs when the MonthPicker is opened through views, one of the props in DatePicker....
Read more >warning: react does not recognize the prop on a dom element.
React does not recognize the `computedMatch` prop on a DOM element. If you intentionally want it to appear in the DOM as a...
Read more >React does not recognize your styled component props when ...
I have encountered this problem in MUI v5.x.x. This problem arise is because of styled() utility function used for creating styled components.
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 FreeTop 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
Top GitHub Comments
@devrnt published
2.0.20
withforwardProps
🥳 thank you so much for landing this! This was all your doing! So happy to see it ingoober
.Landed here after using the cxs project which had similar goals but is no longer actively maintained. That library solved the problem by automatically stripping properties defined on propTypes (https://github.com/cxs-css/cxs/blob/eb934203a17e07aec63e971c3b87068e911b5b6e/src/component.js#L11) In combination with a babel transform that generates the propTypes from typescript typings, the developer experience was pretty darn good, with the obvious downside of having to ship propTypes in production.
Some might find the small increase in bundle size worth it to not have to prefix every style prop, especially when integrating with something like styled-system. I would also welcome the ability to pass off the burden to the developer via a shouldForwardProp function like what emotion exposes. Or perhaps a babel plugin could be used to generate an optimal black/white list of props so the library wouldn’t have to ship with an exhaustive list…idk just thinking out loud. I just know that I’ve seen the magical prefix approach pitched in numerous style libraries and it always seemed like more people were against it than for it…then again I could be biased on that front 😃 Either way, this library is looking like an attractive alternative to cxs and I plan on giving it a spin soon!