Support single objects for meta prop
See original GitHub issueWhile 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:
- Created 7 years ago
- Comments:8 (3 by maintainers)
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.
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.