s-yadav / react-meta-tags

Handle document meta/head tags in isomorphic react with ease.
MIT License
226 stars 47 forks source link

Script tag JSON-LD render twice! #34

Open Alchy-web opened 4 years ago

Alchy-web commented 4 years ago

I have included the in my JSX. Why does my script tag render twice?

the first script tag returns undifined values, and the second one returns the correct values, i have added async & defer to my script tag but in vain!!

<MetaTags>
            <script type="application/ld+json">
            {`
              {
                "@context": "https://schema.org/",
                "@type": "CreativeWorkSeries",
                "name": "${this.state.name}",
                "aggregateRating": {
                  "@type": "AggregateRating",
                  "ratingValue": "${this.state.rating}",
                  "bestRating": "5",
                  "ratingCount": "${this.state.count}"
                }
              }
            `}
            </script>
</MetaTags>
bertyhell commented 4 years ago

I opened a PR to fix this: https://github.com/s-yadav/react-meta-tags/pull/35