claus / storyblok-rich-text-react-renderer

A React renderer for Storyblok rich text content
MIT License
86 stars 16 forks source link

textStyleMarkResolver undefined color error #38

Closed pedrosousa13 closed 3 months ago

pedrosousa13 commented 1 year ago

We just updated this package on our project and are now getting:

TypeError: Cannot destructure property 'color' of 'undefined' as it is undefined.
--
15:37:42.389 | at textStyle

We only have 1 resolver set

const textChildren = render(content, {
    nodeResolvers: {
      [NODE_PARAGRAPH]: paragraphRenderer,
    },
  });

Any idea what could be causing this? Do we have explicitly set a MARK_TEXT_STYLE?

claus commented 1 year ago

NODE_PARAGRAPH resolvers do not take a second argument (only children are passed). Judging from that error message, it looks like you indeed want a MARK_TEXT_STYLE resolver.

pedrosousa13 commented 1 year ago

All my paragraphRenderer is doing is this:

const paragraphRenderer = (children) => (
    <Text>
      {children}
    </Text>
  );
claus commented 1 year ago

Weird! I'll look into that.

claus commented 1 year ago

Hmm i can't reproduce it. Could you do me a favor and add a MARK_TEXT_STYLE resolver? Something like this:

markResolvers: {
  [MARK_TEXT_STYLE]: (children, props) => {
    console.log(props);
    return <span>{children}</span>
  },
}

And see if you get any logs in your console? Or any other errors?

claus commented 1 year ago

I just published 2.7.5 that does some sanity checking for missing attributes. Please let me know if that helps.

pedrosousa13 commented 1 year ago

Thank you for that. Sorry I haven't had time to properly test today. I will do so tomorrow 🙂