CharlesMangwa / react-native-simple-markdown

📜 React Native Markdown component (iOS & Android).
https://www.npmjs.com/package/react-native-simple-markdown
MIT License
414 stars 134 forks source link

Simple Markdown fails with `Unexpected view type nested under text node` #100

Open Alanz2223 opened 6 years ago

Alanz2223 commented 6 years ago

Hello, I've tried all markdown libraries and all of them seem to have an error parsing basic markdown due to how react native Android renders components. The error seems to occur when you try nesting components in your markdown, for example something like this (view it raw since github parses it)

or

I get the following error

Unexpected view type nested under text node: class com.facebook.react.uimanager.LayoutShadowNode

a simple list with a nested list of links fails... Would anyone have a simple and elegant solution to this problem?

I guess the best solution would be to convert the text tag into a view and wrap the text in a text tag?

ollyde commented 5 years ago

I've been hunting for a decent mobile markdown editor for days now. No luck they are all broken.

marudy commented 5 years ago

Hey guys, any update / solution for this one?

lucasromanojf commented 5 years ago

Mine fails when using lists, like:

ollyde commented 5 years ago

I gave up, just use a WebView with https://quilljs.com/ << Best one.

lucasromanojf commented 5 years ago

@voidstarfire I'll take a look, thanks for the tip!

atamano commented 5 years ago

here is a quickfix, you'll need to add a patch:

patch-package
--- a/node_modules/react-native-simple-markdown/rules.js
+++ b/node_modules/react-native-simple-markdown/rules.js
@@ -141,7 +141,7 @@ export default (styles) => ({
   },
   paragraph: {
     react: (node, output, state) => {
-      return createElement(View, {
+      return createElement(Text, {
         key: state.key,
         style: styles.paragraph
       }, output(node.content, state))
ollyde commented 5 years ago

I ended up using Quill. It's excellent and has lots of nice UI/Formatting automations.