Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional tags throw error #255

Closed
irisSchaffer opened this issue Mar 24, 2017 · 3 comments
Closed

Optional tags throw error #255

irisSchaffer opened this issue Mar 24, 2017 · 3 comments

Comments

@irisSchaffer
Copy link

irisSchaffer commented Mar 24, 2017

Version: 5.0.0
React Version: 15.4.2

I'm experiencing problems with rendering optional tags as so:

{track.getIn(['meta', 'description']) && (
    <meta name="description" content={track.getIn(['meta', 'description'])} />
)}

Gives me a TypeError: Cannot read property 'props' of null. I believe it is this line that is throwing the error: https://github.com/nfl/react-helmet/blob/master/src/Helmet.js#L201

If I, however, go with something like

{track.getIn(['meta', 'description']) && (
    <meta name="description" content={track.getIn(['meta', 'description'])} />
) || <meta />}

everything works fine and I get the correct description (which was set in the parent).

@doctyper
Copy link
Contributor

Hm. We do test this specific scenario in our unit tests. Could you post a more reproducible example without the dependency on track.getIn?

@irisSchaffer
Copy link
Author

Sure, of course, sorry! it resolves to undefined on the first render, so:

{undefined && (
    <meta name="description" content={undefined} />
)}

silly test case, but it seems to still receive some form of child, and therefore breaks :/
Mind you, I also have other children within Helmet:

<Helmet>
    <title>Test Title</title>

    {undefined && (
        <meta name="description" content={undefined} />
    )}
</Helmet>

@doctyper
Copy link
Contributor

@irisSchaffer Fixed in [email protected].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants