kodyl / react-document-meta

HTML meta tags for React-based apps. Works for both client- and server-side rendering, and has a strict but flexible API.
MIT License
320 stars 23 forks source link

Existing tags from server markup ignored, ends up with duplicate tags #44

Closed karlmacklin closed 6 years ago

karlmacklin commented 6 years ago

I'm not sure if I'm missing something obvious here, but:

My use case is a SPA where the first rendered html from the server already contains things like title, description, canonical etc. When my DocumentMeta enabled React app then is rendered on top, I end up with duplicate tags for all these.

Is there a way for DocumentMeta to 'hook on' to the existing tags on use those instead? I am using react-router so when navigating the site, the second set (the duplicates) are updated correctly.

I am not using any React server side rendering. It is not an option currently (due to SEO reasons) to not have the server render these tags.

karlmacklin commented 6 years ago

I solved this by making sure my server rendered tags all included the data-rdm attribute. Good enough for my use case.

danieljuhl commented 6 years ago

You are right - we use data-rdm to ensure we don't clear other meta tags. If you used the SSR example and included DocumentMeta in your server side rendering, it would automatically add data-rdm to the tags inserted on the server.