block-content-to-react icon indicating copy to clipboard operation
block-content-to-react copied to clipboard

Pass in additional props to serialisers from render level

Open ppozniak opened this issue 3 years ago • 0 comments

It's more of a question, but wanted to see if it's possible and if we could turn it into a feature.

Currently each mark serialiser is getting only props from a mark, but I need to use additional props that will be passed to <PortableText />.

Example:

export const PortableText = createPortableTextComponent({
  ...sanityConfig,
  serializers: {
    marks: {
       someSerializer(props, propsFromPortableText) {
           return <span>{props.children} {propsFromPortableText.something}</span>
       }
    },
  },
});

<PortableText blocks={blocks} extraProps={{ something: 50 }} />

Any ideas?

ppozniak avatar Jan 26 '22 18:01 ppozniak