Open csi-lk opened 7 years ago
Our unit tests definitely test this case. My Title
should be a string. Hmmm.... What's your version of React?
I'm also getting this, though if I use <Helmet title="My Title">
instead it works. Running React 15.5.4.
Some elements work such as meta
and link
, but this doesn't for e.g. (from README):
<script src="http://include.com/pathtojs.js" type="text/javascript" />
Error: Helmet expects a string as a child of <script>. Did you forget to wrap your children in braces? ( <script>{``}</script> ) Refer to our API for more information.
at HelmetWrapper.warnOnInvalidChildren
I'm using hyperx instead of JSX.
I encountered similar problem with following code:
<Helmet>
<title>Product - { item.name }</title>
</Helmet>
Fixed using string literal
<Helmet>
<title>{ `Product - ${ item.name }` }</title>
</Helmet>
yep just ran into this as well. Above solution is a good workaround.
This is rather annoying when trying to do internationalization. Just allow a node.
Would love it if nodes were allowed as well. It just seems a bit silly at the moment. It's not that much more, but the first is much easier to read.
Right now, I have to turn this:
<Helmet>
<title>Default Title{subtitle && `: ${subtitle}`}</title>
</Helmet>
Into this:
<Helmet>
<title>{subtitle ? `Default Title: ${subtitle}` : `Default Title`}</title>
</Helmet>
Just like OP I'm getting these warnings even though all my titles are explicitly wrapped as strings. This is more annoying than anything but would like to see this fixed.
react-helmet@6.1.0
@mikedpad or you can write it, if you prefer, like so:
<Helmet>
<title>{`Default Title${ subtitle ? ': '+subtitle : '' }`}</title>
</Helmet>
I encountered similar problem with following code:
<Helmet> <title>Product - { item.name }</title> </Helmet>
Fixed using string literal
<Helmet> <title>{ `Product - ${ item.name }` }</title> </Helmet>
Thank you! Your suggestion worked perfect!
Thank you. @codler
Using the first example in the
readme.md
I get:
Even if I change it to
I get the same issue
Any ideas?
Edit see workaround below: https://github.com/nfl/react-helmet/issues/274#issuecomment-345241784