datocms / structured-text

MIT License
22 stars 7 forks source link

React Native Support #25

Closed Bob-MYMC closed 1 year ago

Bob-MYMC commented 1 year ago
  1. Does the library have an official component for React Native to display the structured-text?

  2. Can this datocms-structured-text-to-html-string function convert the structured-text to html string?

The following example does not work properly Instead of returning <p><strong>Hello</strong><u> world!</u></p> It returns <p></p>

render({
  type: 'root',
  children: [
    {
      type: 'paragraph',
      content: [
        {
          type: 'span',
          value: 'Hello',
          marks: ['strong'],
        },
        {
          type: 'span',
          value: ' world!',
          marks: ['underline'],
        },
      ],
    },
  ],
}); // -> <p><strong>Hello</strong><u> world!</u></p>
stefanoverna commented 1 year ago

Here's a working example: https://codesandbox.io/s/zealous-flower-7io5tt?file=/src/index.ts

The argument you're passing to the render() function in your example is not a valid structured text... the content attribute should be children!

... and we don't have (yet) an official React Native component to render structured text 😕