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

bug(docs): className does not work with toString()

Open cpboyd opened this issue 5 years ago • 1 comments

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

As stated in: https://github.com/nfl/react-helmet/blame/master/README.md#L216

    {/* body attributes */}
    <body className="root" />

This specific case using a JSX <body> component may work, but <Helmet bodyAttributes={{ className: 'root' }} /> does not since toString() results in the generated HTML attribute className instead of class.

At the very least, the inconsistency between the JSX component notation and the attribute notation should be documented.

The inconsistency between toString() and toComponent() is already documented in #300.

Paste the link to your CodeSandbox (https://codesandbox.io/s/new) example below:

https://codesandbox.io/s/falling-night-qeu66

What is the expected behavior?

toString() and toComponent() should render the same.

Which versions of React and react-helmet, and which browser / OS are affected by this issue? Did this work in previous versions of React and/or react-helmet? Latest of both; all browsers. No, it probably has never worked.

cpboyd avatar Sep 28 '20 16:09 cpboyd

@cpboyd I like this! Though tbh, the body attribute object notation would expect a class attribute... In a react usage I can see your point. Though react-helmet is not react ;-) and as such you should use the class attribute.

Though a nice PR idea, support the old and the new? Will look forward to the PR.

AubreyHewes avatar Oct 09 '20 02:10 AubreyHewes