react-native-markdown-renderer
react-native-markdown-renderer copied to clipboard
Default `hardbreak` breaks on Android
When trying to render the following
**2. Find a pattern (addition, subtraction) \n With five components**
It breaks on android, specifically where the " \n " is (note the two spaces that cause the hardbreak)
On android this error occurs when rendering
Unexpected view type nested under text node: class com.facebook.react.uimanager.LayoutShadowNode
According to https://github.com/facebook/react-native/issues/10232 this is only a problem for android and not iOS as your able to put view inside text in iOS
The default render rule for hardbreak is a view which causes view inside text to occur. The default should be changed so that it does not break on android.
To get around this I used this render rule for hardbreak instead
hardbreak: (node, children, parent, styles) => (
<Text key={node.key} styleSheet={styles.hardbreak}>
{"\n"}
</Text>,
),
This has been fixed in v3.2.8 see ticket #56 describing the same issue, or i am missing something. Thx for reporting this anyway.
@mientjan
I had another look to see if I did a mistake.
I am on v3.2.8 and I still got the error above.
I'm not exactly sure how the markdown is converted to react-native jsx but the issue lies in hardbreak generating a View being contained in Text components where on android this is not allowed .
So either:
hardbreakneeds to either splitTextcomponents on the most outer level and implement thehardbreak Viewbetween theTextparagraphs,- OR hardbreak needs to be done through raw text to fit with react-native current standards as my PR (although since its a hard break it should probably contain 2 new lines rather then 1).
Thanks for looking at this.
I can confirm that this is still a real problem in 3.2.8.
__some bold text
on two lines__
In this case there is a hardbreak after the word text