Skip to content

Update unknown props warning page #7848

Closed

Description

@amsdamsgram

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!

Activity

  1. gaearon commented on Oct 27, 2016

    @gaearon
    Collaborator

    Would you like to submit a PR to the doc page?

  2. amsdamsgram commented on Oct 27, 2016

    @amsdamsgram
    Author

    Sure

  3. bennick commented on Jan 5, 2017

    @bennick

    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

    const VideoPlayer = ({ id }) => {
      return (
        <iframe src={`https://player.vimeo.com/video/${id}`} allowFullScreen webkitallowfullscreen mozallowfullscreen />
      )
    }

    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.

  4. podrivo commented on Aug 30, 2017

    @podrivo

    @bennick same thing here

  5. bennick commented on Aug 30, 2017

    @bennick

    @podrivo Yea I ended up using dangerouslySetInnerHTML 😞

  6. daviddelusenet commented on Sep 4, 2017

    @daviddelusenet

    +1

  7. gaearon commented on Sep 4, 2017

    @gaearon
    Collaborator

    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.

  8. podrivo commented on Sep 4, 2017

    @podrivo

    @gaearon +1 means "my thoughts exactly" or "me too". ref

  9. gaearon commented on Sep 4, 2017

    @gaearon
    Collaborator

    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.

  10. gaearon commented on Oct 5, 2017

    @gaearon
    Collaborator

    To clarify, all of the above attributes work in React 16:

    const VideoPlayer = ({ id }) => {
      return (
        <iframe
          src={`https://player.vimeo.com/video/${id}`}
          allowFullScreen="true"
          webkitallowfullscreen="true"
          mozallowfullscreen="true"
        />
      )
    }

    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.

  11. bennick commented on Oct 5, 2017

    @bennick

    ah thanks for the clarification @gaearon

  12. podrivo commented on Oct 5, 2017

    @podrivo

    Indeed. Thanks @gaearon!

  13. rwieruch commented on Oct 6, 2017

    @rwieruch

    Thank you 🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions