How to render an actual object HTML component like <p>paragraph</p>
5ervant opened this issue · 1 comments
5ervant commented
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`."
5ervant commented
The solution is to use ReactDOMServer
:
import ReactDOMServer from 'react-dom/server';
// ...
<HTMLView value={ReactDOMServer.renderToStaticMarkup(<Paragraph />)} />