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.

v4 passes through unknown HTML attribute to the DOM

See original GitHub issue

Environment

npm packages:

  1. react: v16.5.2
  2. react-dom: v16.5.2
  3. styled-components: v4.0.2

Reproduction

https://codesandbox.io/s/zn5vrk0vpm

Expected Behavior

https://codesandbox.io/s/20xlp242pr There is no unknown-prop warning if I’m using styled(styled.button).attrs({ customProp }) with styled-components v3.4.10.

Actual Behavior

There is unknown-prop warning with styled-components v4. 2018-10-20 11 33 29

If this is not a bug, and there is something missing. Please let me know, thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

6reactions
jarodtaylorcommented, Aug 16, 2019

Will this be resolved in v5 for the Link (or any other custom components)?

6reactions
mbrownecommented, Nov 21, 2018

I’m seeing a similar issue with the new as prop, e.g.:

...
import { Link } from 'react-router-dom';

const StyledLink = styled.a`
    ${p => (p.linkStyle === 'upperCase' ? 'text-transform: uppercase' : '')}
`

<StyledLink as={Link} linkStyle="upperCase" to="/">test link</StyledLink>

Warning: React does not recognize the linkStyle prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase linkstyle instead. If you accidentally passed it from a parent component, remove it from the DOM element.

Is this related to an existing issue or should I open a new issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

What happens if an invalid/nonstandard HTML attribute is ...
In practice, browsers ignore unknown attributes as far as HTML alone is considered. However, they do not ignore them in CSS; an attribute...
Read more >
Unknown Prop Warning - React
The unknown-prop warning will fire if you attempt to render a DOM element with a prop that is not recognized by React as...
Read more >
Attributes and properties - The Modern JavaScript Tutorial
When the browser parses the HTML to create DOM objects for tags, it recognizes ... attribute for one element can be unknown for...
Read more >
HTML attribute: crossorigin - MDN Web Docs
anonymous. Request uses CORS headers and credentials flag is set to 'same-origin' . There is no exchange of user credentials via cookies ...
Read more >
3.2 Elements — HTML5 - W3C
Elements, attributes, and attribute values in HTML are defined (by this specification) ... user agents should pass unknown language tags through unmodified.
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