Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions htmlToElement.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {StyleSheet, Text} from 'react-native';
import {StyleSheet, Text, View} from 'react-native';
import htmlparser from 'htmlparser2-without-node-native';
import entities from 'entities';

Expand All @@ -11,7 +11,7 @@ const defaultOpts = {
bullet: '\u2022 ',
TextComponent: Text,
textComponentProps: null,
NodeComponent: Text,
NodeComponent: View,
nodeComponentProps: null,
};

Expand Down Expand Up @@ -69,7 +69,7 @@ export default function htmlToElement(rawHtml, customOpts = {}, done) {

const {TextComponent} = opts;

if (node.type === 'text') {
if (node.type === 'text' || !node.children) {
const defaultStyle = opts.textComponentProps ? opts.textComponentProps.style : null;
const customStyle = inheritedStyle(parent);

Expand Down Expand Up @@ -154,10 +154,10 @@ export default function htmlToElement(rawHtml, customOpts = {}, done) {
style={!node.parent ? styles[node.name] : null}
onLongPress={linkLongPressHandler}
>
{linebreakBefore}
{linebreakBefore && <Text>{linebreakBefore}</Text>}
{listItemPrefix}
{domToElement(node.children, node)}
{linebreakAfter}
{linebreakAfter && <Text>{linebreakAfter}</Text>}
</NodeComponent>
);
}
Expand Down