question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support single objects for meta prop

See original GitHub issue

While passing meta values to <Helmet>, the provided API is an array of objects:

<Helmet
  meta={[
    { name: "description", content: "Helmet application" },
    { property: "og:type", content: "article" },
  ]}
/>

A co-worker recently tried passing a single object instead:

<Helmet
  meta={{ name: "description", content: "Helmet application" }}
/>

The consequences of this were rather severe; because we render on the server, React Helmet’s exception crashed a server crash. A careless deploy meant we spent quite a long time trying to figure out why our server kept going down.

Please understand that we accept responsibility for this, it was totally our fault for misunderstanding the documentation 😃

That said, it could be helpful to prevent similar mistakes by other users to support the ‘single object’ syntax, for when only a single meta property needs to be set.

Would be happy to look into this and open a PR, if it’s deemed a worthwhile inclusion!

Thanks.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
joshwcomeaucommented, Mar 13, 2017

Thanks @potench! #233 is awesome.

@jeffboyus I believe that they’ve since walked back the statement about ditching PropTypes. Unless there’s news that they’ve committed to removing them, I wouldn’t speculate.

1reaction
doctypercommented, Jan 6, 2017

It’s a valid point, we should explore throwing a more descriptive error when users provide invalid values.

I believe we’re planning on adding and exporting Flow types to Helmet, which will also surface those errors to developers who use Flow types.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WP 5.3 Supports Object and Array Meta Types in the REST API
With WordPress 5.3, the register_meta functions (including register_post_meta ) now support the 'object' and 'array' data types.
Read more >
Working with objects - JavaScript - MDN Web Docs - Mozilla
Defining properties for all objects of one type. You can add a property to all objects created through a certain constructor using the...
Read more >
metaprop: Meta-analysis of single proportions - Rdrr.io
Description. Calculation of an overall proportion from studies reporting a single proportion. Inverse variance method and generalised linear mixed model (GLMM) ...
Read more >
Describe property of MATLAB class - MathWorks
Obtain a meta.property object from the meta.class PropertyList property, which contains an array of meta.property objects, one for each class property.
Read more >
Liquid objects: metafield - Shopify.dev
... and functional elements that help you to build interactivity. Objects might represent a single data point, or contain multiple properties.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found