react-helmet-async icon indicating copy to clipboard operation
react-helmet-async copied to clipboard

Meta array entry is omitted when it has "itemProp" property

Open shwao opened this issue 4 years ago • 0 comments

When you add an entry to the meta array with the itemProp property, it will be ignored.

Example:

<Helmet
  meta={[
    {
      name: "description",
      itemProp: "description",
      content: "Test Description"
    }
  ]}
/>

Output of helmet.meta.toComponent() or helmet.meta.toString() would be empty. Remove the property itemProp and it would be <meta data-rh="true" name="description" content="Test Description" />.

Adding the meta information as an element works!

<Helmet>
  <meta name="description" itemProp="description" content="Test Description" />
<Helmet/>

Output: <meta data-rh="true" name="description" itemprop="description" content="Test Description" />

When you change the name property of the meta entry to a getter function you can see that it is used in the client but not on the server:

<Helmet
  meta={[
    {
      get name() {
        console.log("called");
        return "description";
      },
      itemProp: "description",
      content: "Test Description"
    }
  ]}
/>

This outputs a console log in the browser, even though the element is nowhere to be found, but not on the server with SSR. When the property itemProp is removed the log also appears on the server.

shwao avatar Nov 07 '20 21:11 shwao