Closed daniloab closed 3 years ago
Do you want to request a feature or report a bug? Bug
What is the current behavior? I have a component wrapped by helmet like the example below:
const getMetaOGTags = () => { return ` <Helmet> <meta property="og:title" content="og title"> <meta property="og:description" content="og description"> <meta property="og:image" content="og image"> <meta property="og:url" content="og url"> <meta property="og:site_name" content="og site"> <meta property="og:locale" content="pt_BR"> <meta property="og:type" content="website"> </Helmet> `; }; return ( <Helmet> <title>React Helmet Test</title> {getMetaOGTags()} </Helmet> );
On the server side, after the ReactDOMServer.renderToString I'm calling the helmet.renderStatic() and trying to render my meta tags.
ReactDOMServer.renderToString
helmet.renderStatic()
The problem is that only the title tag is rendered. The meta tags do not work.
const helmet = Helmet.renderStatic(); return ` <!doctype html> <html lang=""> <head> <meta charset="utf-8" /> ${helmet.title.toString()} <meta name="viewport" content="width=device-width, initial-scale=1"> ${helmet.meta.toString()} ${helmet.link.toString()} </head> <body ${helmet.bodyAttributes.toString()}> <div id="root">${html}</div> <script> window.__initialProps__ = ${serialize(initialProps, { isJSON: true, })}; </script> </body> </html> `;
result of render
I add some console.logs and the result is:
What is the expected behavior? I want to render the meta tags on my server side correctly
**Which versions of React and react-helmet, and which browser / OS are affected by this issue?
I was passing a string instead a jsx on my getMetaOGTags
getMetaOGTags
Do you want to request a feature or report a bug? Bug
What is the current behavior? I have a component wrapped by helmet like the example below:
On the server side, after the
ReactDOMServer.renderToString
I'm calling thehelmet.renderStatic()
and trying to render my meta tags.The problem is that only the title tag is rendered. The meta tags do not work.
result of render
I add some console.logs and the result is:
What is the expected behavior? I want to render the meta tags on my server side correctly
**Which versions of React and react-helmet, and which browser / OS are affected by this issue?