Component API props are passed to DOM element
See original GitHub issueHi!
Thanks for the best css-in-js library! We’re using Component API in our application, and I noticed odd behaviour in a new version: all props matching css classes are passed to DOM elements. As far as I remember astroturf filtered props earlier.
Example:
let Base = styled.div`
position: relative;
…
&.isBig {
size: 32px;
}
`
…
return React.createElement(Base, { isBig }, …)
And now I’m getting:
Warning: React does not recognize the `isBig` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `isbig` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
Is it correct behaviour and we have to filter props manually?
Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Passing Props to a Component - React Docs
React components use props to communicate with each other. Every parent component can pass some information to its child components by giving them...
Read more >Getting warning from props passed in MUI styled components ...
I have a similar issue with a custom prop on component created with styled from ... component that doesn't pass the custom props...
Read more >How passing props to component works in React
Master how to pass props (properties) to components in React with this useful beginner's guide, including demo code.
Read more >Passing Elements as Props in React | by David Barral - Medium
In this story we are going to see a simple technique that allows you to write friendly customizable components with simple APIs, just...
Read more >Unsupported props are being passed to DOM elements #2
If you accidentally passed it from a parent component, remove it from the DOM element. React does not recognize the 'valuePropFn' prop on...
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
i think this is just an oversight on my part though – i think the right thing would be to support these props being null-y. wdyt?
@taion You right, it was the source of the issue.
But I hope many developers will make the same mistake. Maybe we should show own warning, that CSS class has the same name as non-bolean prop