react-native-simple-markdown icon indicating copy to clipboard operation
react-native-simple-markdown copied to clipboard

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

Open Alanz2223 opened this issue 6 years ago • 7 comments

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)

  • [Leetcode Problem] (https://google.com)

    A general classification of the topics, and a summary of the problem-solving ideas for each type of question.

or

  • [I. Basic Concepts] (#1 - Basic Concept)

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?

Alanz2223 avatar Aug 24 '18 20:08 Alanz2223

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

ollyde avatar Dec 06 '18 15:12 ollyde

Hey guys, any update / solution for this one?

marudy avatar Jan 08 '19 10:01 marudy

Mine fails when using lists, like:

  • bla bla bla
  • bla bla bla ....

lucasromanojf avatar Jan 22 '19 14:01 lucasromanojf

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

ollyde avatar Jan 22 '19 14:01 ollyde

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

lucasromanojf avatar Jan 22 '19 14:01 lucasromanojf

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))

atamano avatar Apr 02 '19 14:04 atamano

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

ollyde avatar Apr 02 '19 14:04 ollyde