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.

More helpful interaction for "React does not recognize the 'propName' prop on a DOM Element"

See original GitHub issue

Do you want to request a feature or report a bug?

Feature

What is the current behavior?

When you pass a unknown prop to a DOM element - common when you pass {...props} to something that turns out to be a div/span/any other DOM element rather than a composite component - you get a warning like so:

Warning: React does not recognize the `propName` prop on a DOM element. ....

If the tree is pretty complicated, especially if you’re using HOCs, it can be very hard to find where this prop has been passed and to which DOM element.

What is the expected behavior?

We had a quick muck around with react-dom and logging the DOM element that triggers this warning allows you to see the element in the DOM and makes it much easier to work out where the prop is being accidentally passed. You can even use the react dev tools to work out exactly which line the component is defined in the code.

Simply logging the element is obviously not the most elegant way of showing the user where the mistake is, but would it be possible to do something in order to make it quicker to fix mistaken prop passing like this?

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

All.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
gpawlikcommented, Jun 3, 2020

Does anybody know why are those warnings displayed with console.error instead of console.warn?

0reactions
stale[bot]commented, Jan 17, 2020

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

React does not recognize the X prop on a DOM element ...
If you accidentally passed it from a parent component, remove it from the DOM element.
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 >
Warning: React does not recognize the `isOpen` prop on a DOM
prop on a DOM element. i got solved this issue. just change tag to Navlink because ActiveClassName is just suported Navlink.
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 >
How to Access Custom Attributes from Event Object in React
Often you need to store information associated with a DOM element. This data might not be useful for displaying data to the DOM,...
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