react-native-htmlview
react-native-htmlview copied to clipboard
Unexpected view type nested under text node

<p><img src="https://user-images.githubusercontent.com/3722860/40227824-219012b2-5ac2-11e8-8ef9-eff05889d76c.png"></p>
When removing the TouchableOpacity
components,or
<img src="https://user-images.githubusercontent.com/3722860/40227824-219012b2-5ac2-11e8-8ef9-eff05889d76c.png">
the error no longer appears。
+1
+1
+1 when I use renderNode to show the img like this issue https://github.com/jsdf/react-native-htmlview/issues/220 if the html content do not include p Tag ,the error will not show up
+1
+1,how to resolve it?
+1 how resolve it?
Does somebody succeeded to solve it?
I finally used webview to show richtext.
After struggling with a similar problem for a long time, I finally found a (somewhat) elegant way to resolve it. As mentioned in an earlier comment the issue is the enclosing p tag. The parser translates it as a Text tag and then you can no longer have any view tags within that Text tag without getting this error.
There are several approaches you might take, but I simply set the parser to convert top level p tags to View tags and then applied a flexDirection of 'row' to the View to give it similar properties. Here's what my code looks like:
if (node.name === 'p' &&
node.parent === null) {
return (
<View key={index} style={styles.messageWrap}>
{defaultRenderer(node.children, parent)}
</View>
);
}
const styles = {
messageWrap: {
flexDirection: 'row',
justifyContent: 'flex-start',
flexWrap: 'wrap'
}
};