jsdf/react-native-htmlview

How to render an actual object HTML component like <p>paragraph</p>

5ervant opened this issue · 1 comments

I'm seeing that react-native-htmlview can render an HTML code in string format.
But how we can render an actual object HTML component like <p>paragraph</p>?

// ./Paragraph.js
export default () => (<p>This is a <span>paragraph</span>.</p>);
import Paragraph from './Paragraph.js'
// ...
    <HTMLView value={<Paragraph />} />

I already tried the above code but just getting a "Warning: Failed prop type: Invalid prop `value` of type `object` supplied to `HtmlView`, expected `string`."

The solution is to use ReactDOMServer:

import ReactDOMServer from 'react-dom/server';
// ...
    <HTMLView value={ReactDOMServer.renderToStaticMarkup(<Paragraph />)} />