sanity-io / block-content-to-react

Deprecated in favor of @portabletext/react
https://github.com/portabletext/react-portabletext
MIT License
161 stars 25 forks source link

Unknown props should be passed as attributes to the container, or don't use a container at all #34

Closed xiata closed 1 year ago

xiata commented 4 years ago

Right now, SanityBlockContent handles the className attribute, but not, for example handle style attribute (very common attribute, surprised me className was accepted but not style). It's confusing that in cases of single nodes, <SanityBlockContent> does not render a container <div> element, but when multiple nodes it does, and when it does render a container, unknown attributes to <SanityBlockContent> are not passed along to the container to render them as attributes.

Please do one of the following:

miracle2k commented 4 years ago

There should be an option to render an array of fragments.

andrevenancio commented 3 years ago

I think render an array of fragments is the solution. you can wrap BlockContent in a container if you need to, but if you don't, then an array of fragments is the ideal solution. Specially for us using CSS in JS I now need to target the container instead of the children I'm expecting.

ehowey commented 3 years ago

Just ran into this and hopping in here to say this as well!

My use case was targeting all of the child elements with CSS styling - doing a full bleed layout using CSS Grid. But because there is a container div this interrupts my ability to use Grid on all of the child elements easily on the page.

rexxars commented 1 year ago

Closing this, as the new @portabletext/react library is the successor to this module. Please see https://github.com/portabletext/react-portabletext