{"action":"created","issue":{"url":"https://api.github.com/repos/nfl/react-helmet/issues/432","repository_url":"https://api.github.com/repos/nfl/react-helmet","labels_url":"https://api.github.com/repos/nfl/react-helmet/issues/432/labels{/name}","comments_url":"https://api.github.com/repos/nfl/react-helmet/issues/432/comments","events_url":"https://api.github.com/repos/nfl/react-helmet/issues/432/events","html_url":"https://github.com/nfl/react-helmet/issues/432","id":395499278,"node_id":"MDU6SXNzdWUzOTU0OTkyNzg=","number":432,"title":"SSR Helmet tags not getting updated","user":{"login":"aronddadi","id":33458886,"node_id":"MDQ6VXNlcjMzNDU4ODg2","avatar_url":"https://avatars3.githubusercontent.com/u/33458886?v=4","gravatar_id":"","url":"https://api.github.com/users/aronddadi","html_url":"https://github.com/aronddadi","followers_url":"https://api.github.com/users/aronddadi/followers","following_url":"https://api.github.com/users/aronddadi/following{/other_user}","gists_url":"https://api.github.com/users/aronddadi/gists{/gist_id}","starred_url":"https://api.github.com/users/aronddadi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aronddadi/subscriptions","organizations_url":"https://api.github.com/users/aronddadi/orgs","repos_url":"https://api.github.com/users/aronddadi/repos","events_url":"https://api.github.com/users/aronddadi/events{/privacy}","received_events_url":"https://api.github.com/users/aronddadi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2019-01-03T09:07:20Z","updated_at":"2019-03-21T05:20:30Z","closed_at":null,"author_association":"NONE","body":"Hi\r\n\r\nAs mentioned in the title, the meta tags delivered by the ssr are not dynamic/the correct ones.\r\n\r\nSo on this project I'm working on we have meta tags (for SEO purposes) which should be dynamic.\r\nI know todays crawlers also index client-sided code but for faster indexation, good practice, and because I'd like to know how it works, I still want to do it.\r\n\r\nHelmet meta tags get updated to the correct ones on the client side, but on the ssr the meta tags that are sent are the generic ones from the app component, and not the ones from the nested components within.\r\n\r\nCode snippet from the server.jsx \r\n\r\n```\r\nexport default function serverRenderer() {\r\n  return (req, res) => {\r\n    const context = {}\r\n    const browserLanguage = 'en'\r\n    const componentTree = (\r\n      <ApolloProvider client={client}>\r\n        <IntlProvider locale={languageSelected} messages={bob}>\r\n          <StaticRouter location={req.url} context={context}>\r\n            <ThemeProvider theme={theme}>\r\n              <App auth={auth} lang={browserLanguage} />\r\n            </ThemeProvider>\r\n          </StaticRouter>\r\n        </IntlProvider>\r\n      </ApolloProvider>\r\n    )\r\n    const sheet = new ServerStyleSheet()\r\n    const markup = renderToString(\r\n      sheet.collectStyles(componentTree)\r\n    )\r\n    const styles = sheet.getStyleTags()\r\n    const helmet = Helmet.renderStatic()\r\n\r\n    const toBeSent = Template({ markup, styles, helmet})\r\n    if (context.url) {\r\n      res.writeHead(301, { Location: context.url })\r\n      res.end()\r\n    } else {\r\n      res.send(toBeSent)\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nIn the  App component there are generic meta tags  + header - main(routes/views) + footer and on the nested views that are shown like I said the meta tags do get updated on the client side, not on the server side, whereas from what I've been reading and hearing when asking around, as the code is, it should be working.\r\n\r\nI tried implementing react-helmet-async, but it did not seem to get me further + from what I've read in the documentation, react-helmet does support child components overwriting helmet meta tags with the same name from parent component.\r\n\r\nThings I'm considering doing but which I don't think are the right answer/ right practices:\r\nMaking almost all the  information of the meta tags states and then passing a method which can modify those to the children\r\nOR \r\nMake a lot of if elses which give the right meta tags depending on the req.url/ window.location.href\r\n\r\nPlease help and have a good day!"},"comment":{"url":"https://api.github.com/repos/nfl/react-helmet/issues/comments/475116074","html_url":"https://github.com/nfl/react-helmet/issues/432#issuecomment-475116074","issue_url":"https://api.github.com/repos/nfl/react-helmet/issues/432","id":475116074,"node_id":"MDEyOklzc3VlQ29tbWVudDQ3NTExNjA3NA==","user":{"login":"divmgl","id":5452298,"node_id":"MDQ6VXNlcjU0NTIyOTg=","avatar_url":"https://avatars1.githubusercontent.com/u/5452298?v=4","gravatar_id":"","url":"https://api.github.com/users/divmgl","html_url":"https://github.com/divmgl","followers_url":"https://api.github.com/users/divmgl/followers","following_url":"https://api.github.com/users/divmgl/following{/other_user}","gists_url":"https://api.github.com/users/divmgl/gists{/gist_id}","starred_url":"https://api.github.com/users/divmgl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/divmgl/subscriptions","organizations_url":"https://api.github.com/users/divmgl/orgs","repos_url":"https://api.github.com/users/divmgl/repos","events_url":"https://api.github.com/users/divmgl/events{/privacy}","received_events_url":"https://api.github.com/users/divmgl/received_events","type":"User","site_admin":false},"created_at":"2019-03-21T05:20:30Z","updated_at":"2019-03-21T05:20:30Z","author_association":"NONE","body":"I'm having the same exact problem. I realize this was already a few months ago so you may not be experiencing this problem but are you still having this issue? If not, what was the fix? I've basically given up on this and now I'm generating the head code both on the server and with the Helmet code on the client-side."}}
{"actor":{"display_login":"divmgl"}}