简体   繁体   中英

React-helmet metaTags are disappears on page change

I made small learning ReactJS based Server Side app. My goal is to share a dynamic post on facebook using React SSR, I have made canvas based app it generates image and I want to set dynamic metaTags to share post on FB.

here my sample code gitRepo ,

I am also facing One more issue when I change page automatically using history.push or Redirect tag in Render, then Rect-helmet won't set metaTags.

Looks like you're setting meta on one page (Project) bizarrely after a POST request is successful. Is it any wonder it doesn't exist in other routes? React helmet calculates the meta dynamically from the react tree, like any React code if it doesn't exist at that point it gets removed.

If you want to share meta across pages then set it higher up eg App.js which all routes share.

Also you're setting it after a saveImage request, not sure if those meta tags will be useful when set at that point.

最后,我使用react-meta-tags而不是react-helmet,它可以帮助我解决此问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM