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.

Component API props are passed to DOM element

See original GitHub issue

Hi!

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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
taioncommented, Oct 9, 2018

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?

1reaction
aicommented, Oct 9, 2018

@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

Read more comments on GitHub >

github_iconTop 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 >

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