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.

React does not recognize the XX prop on a DOM element

See original GitHub issue

Description 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
cristianbotecommented, Jan 13, 2021

@devrnt published 2.0.20 with forwardProps 🥳 thank you so much for landing this! This was all your doing! So happy to see it in goober.

1reaction
jayalfredprufrockcommented, Dec 28, 2020

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!

Read more comments on GitHub >

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

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