React-helmet: Override to delete meta property?

Created on 6 Jul 2016  路  3Comments  路  Source: nfl/react-helmet

I have an Helmet element and want to use it to delete a meta property (og:image:height) set in a parent component.

I've tried:

<Helmet
      meta={{ property: 'og:image:height', content: null }}
>

But can still see the og:image:height meta tag in the generated HTML. I was wondering if there's any way to remove it entirely.

Most helpful comment

I came across this today , wanted to remove the meta tags added by Gatsby, the only option was to override it with an empty value. I wish there was a way to delete a property.

All 3 comments

@olalonde Thanks for your interest in Helmet. In your example, the meta prop needs to be an array of objects. Aside from that, the API doesn't offer a way to remove parent tags, but only a way to override them with different values. If you need your tag to only show up in certain children components, you may need to move your tag down a level into the specific children you would like to use it.

@cwelch5

So, I stumbled on this today and was curious if this might be a viable solution.

const elem = document.querySelectorAll('meta[name=apple-itunes-app]')[0];
elem.remove();

The issue I'm having is that I want this tag present on _almost every single view_ and I'd love to reduce boilerplate. I could, of course, use a shared <DefaultHelmet /> and inject on the top level; just curious why this feature isn't present or lacking, or if you might have any other recommended solutions.

I came across this today , wanted to remove the meta tags added by Gatsby, the only option was to override it with an empty value. I wish there was a way to delete a property.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MiguelMachado-dev picture MiguelMachado-dev  路  4Comments

michaelBenin picture michaelBenin  路  3Comments

lxe picture lxe  路  5Comments

bradbarrow picture bradbarrow  路  4Comments

aravind12345 picture aravind12345  路  5Comments