dangerouslySetInnerHTML not working on <title> tag
Author: davidyeiserCreated Oct 13, 2017Updated May 19, 2026
I have a page title with coded HTML entities that I would like to render as: “New Post”
It's delivered to React as: “New Post”
For rendering the title on the page I use this code and it works as expected:
<ArticleTitle><span dangerouslySetInnerHTML={{__html: post.title}} /></ArticleTitle>Returns:
“New Post”
However, when I try to do the same thing for the <title> tag I get an [object Object] returned:
<Helmet>
<title dangerouslySetInnerHTML={{__html: post.title}} />
</Helmet>Returns:
<title dangerouslysetinnerhtml="[object Object]" data-react-helmet="dangerouslySetInnerHTML">“New Post” · RAM</title>There's an original title that is set per page by the server, however as you browse around I'm using React to update it on the client-side. If I remove the server-side <title> tag, no <title> tag is rendered at all by the front end.
Is this issue related to react-helmet or something else going on?
Source: nfl/react-helmet