Closed leonardoanalista closed 3 years ago
The default container is a div. This creates an empty div that wrapping every element rendered. Sometimes we have invalid HTML markup because the contents are rendered inside a Heading tag. Heading tag can only contain inline elements: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#phrasing_content
div
Heading
Validator used: https://validator.w3.org/nu
Here is the code: https://github.com/sanity-io/block-content-to-hyperscript/blob/d9d5adac36d50c0c012f7bb4099fb6f3fa67b382/src/serializers.js#L156
Should the default container value be just a Fragment for React apps?
Fragment
I know we can just set the container prop to a Fragment. I am wondering if there are any other implications I am unable to see?
You can do this by <BlockContent serializers={{ container: ({ children }) => children, /* your types defs, etc */ }} />
<BlockContent serializers={{ container: ({ children }) => children, /* your types defs, etc */ }} />
I already do this with significantly more complicated logic.
The default container is a
div
. This creates an emptydiv
that wrapping every element rendered. Sometimes we have invalid HTML markup because the contents are rendered inside a Heading tag.Heading
tag can only contain inline elements: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#phrasing_contentValidator used: https://validator.w3.org/nu
Here is the code: https://github.com/sanity-io/block-content-to-hyperscript/blob/d9d5adac36d50c0c012f7bb4099fb6f3fa67b382/src/serializers.js#L156
Should the default container value be just a
Fragment
for React apps?I know we can just set the container prop to a Fragment. I am wondering if there are any other implications I am unable to see?