You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the current behavior?
If I write a JSX component without an upper case, React gives me the unknown prop warning
I finally remember that
React's JSX uses the upper vs. lower case convention to distinguish between local component classes and HTML tags.
But I think it could be useful to remind it in the unknown props warning page as a reason of this warning.
I spent some time debugging and not understanding this warning in this case. And I might not be the only one!
What is the expected behavior?
Update unknown props warning page and add a reason this warning could be appearing:
4. You are using a JSX component without an upper case. React treats it as an HTML tag and probably doesn't recognize its props. React's JSX uses the upper vs. lower case convention to distinguish between local component classes and HTML tags.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
I use React 15.2.1
Let me know if you think it could be useful or it's just me who hasn't been enough careful!
I understand the reasoning behind the props warning but what is the recommended way to apply non standard but valid html attributes that are not on the whitelist?
For example take this component that simply wants to render a video via an iframe
constVideoPlayer=({ id })=>{return(<iframesrc={`https://player.vimeo.com/video/${id}`}allowFullScreenwebkitallowfullscreenmozallowfullscreen/>)}
Out of the 3 attributes (allowFullScreen, webkitallowfullscreen, mozallowfullscreen) only allowFullScreen is on the whitelist.
While webkitallowfullscreen and mozallowfullscreen are depreciated providers like Vimeo still have you use them.
What is the recommended way to use them without getting this warning? I have used dangerouslySetInnerHTML in order to avoid the warning but I am not a fan of this approach.
Whatever the answer perhaps this could be included in the docs. Cheers.
Reacted by Jon Oropeza, Michael Kushlan, Aubron Wood, fdsaaa, chivorotkiv, Owen TM, Wemyss, Pavel Khritonenko, Ville, Cameron Drake and 8 more
I understand. +1’s are usually completely useless on the issues because they just spam the notifications for everyone but don’t give any valuable insight or new information. If you wish to “+1” an issue you can do so by using emoji “reactions” on GitHub that are available on every post.
In my comment, I meant that I don’t understand what is here to +1. The problem reported in this issue (docs not mentioning something) has already been fixed.
Reacted by Pedro Ivo Hudson, Ethan Lin and David de Lusenet
To clarify, all of the above attributes work in React 16:
constVideoPlayer=({ id })=>{return(<iframesrc={`https://player.vimeo.com/video/${id}`}allowFullScreen="true"webkitallowfullscreen="true"mozallowfullscreen="true"/>)}
You just need to specify "true" explicitly for them.
This is because different unknown attributes treat booleans in different ways (e.g. "false" can be considered truthy). So we ask you to explicitly specify them as strings.
Reacted by Pedro Ivo Hudson, Robin Wieruch, Vlatko Koudela, Peder Klev, Madalena, Federico Biccheddu, Umar Muneer and Md Maruf Hossain
Activity
gaearon commentedon Oct 27, 2016
Would you like to submit a PR to the doc page?
amsdamsgram commentedon Oct 27, 2016
Sure
bennick commentedon Jan 5, 2017
I understand the reasoning behind the props warning but what is the recommended way to apply non standard but valid html attributes that are not on the whitelist?
For example take this component that simply wants to render a video via an iframe
Out of the 3 attributes (
allowFullScreen,webkitallowfullscreen,mozallowfullscreen) onlyallowFullScreenis on the whitelist.While
webkitallowfullscreenandmozallowfullscreenare depreciated providers like Vimeo still have you use them.What is the recommended way to use them without getting this warning? I have used
dangerouslySetInnerHTMLin order to avoid the warning but I am not a fan of this approach.Whatever the answer perhaps this could be included in the docs. Cheers.
podrivo commentedon Aug 30, 2017
@bennick same thing here
bennick commentedon Aug 30, 2017
@podrivo Yea I ended up using
dangerouslySetInnerHTML😞daviddelusenet commentedon Sep 4, 2017
+1
gaearon commentedon Sep 4, 2017
The page has been updated. I’m not sure what +1 refers to but I’ll close this.
What @bennick is asking is tracked in #140. And I think we fixed this in master.
podrivo commentedon Sep 4, 2017
@gaearon +1 means "my thoughts exactly" or "me too". ref
gaearon commentedon Sep 4, 2017
I understand. +1’s are usually completely useless on the issues because they just spam the notifications for everyone but don’t give any valuable insight or new information. If you wish to “+1” an issue you can do so by using emoji “reactions” on GitHub that are available on every post.
In my comment, I meant that I don’t understand what is here to +1. The problem reported in this issue (docs not mentioning something) has already been fixed.
gaearon commentedon Oct 5, 2017
To clarify, all of the above attributes work in React 16:
https://jsfiddle.net/Luktwrdm/
You just need to specify
"true"explicitly for them.This is because different unknown attributes treat booleans in different ways (e.g.
"false"can be considered truthy). So we ask you to explicitly specify them as strings.bennick commentedon Oct 5, 2017
ah thanks for the clarification @gaearon
podrivo commentedon Oct 5, 2017
Indeed. Thanks @gaearon!
rwieruch commentedon Oct 6, 2017
Thank you 🥇