Benjamin-Dobell / react-native-markdown-view

MarkdownView for React Native
MIT License
190 stars 77 forks source link

Views nested within a <Text> must have a width and height #5

Open samdoj opened 7 years ago

samdoj commented 7 years ago

This occurs when using bold, and that was a simple fix. I just added width and height as null, but I meet this error when trying to display a list of links.

Benjamin-Dobell commented 7 years ago

@samdoj Could you please post some example/reproduction markdown?

Sunshine168 commented 6 years ago

i have the same issues。 api eg: https://cnodejs.org/api/v1/topic/592917b59e32cc84569a7458 md is in data's content

pandeyrohit51 commented 6 years ago

I am using Markdown view inside a Text Element and it gives me the same error. I am using a plugin that truncates the text and adds 'Continue reading' . I am using Markdown inside it.

Code :

<View style={{flexDirection:'row',paddingBottom:5}}>
        <ReadMore
              numberOfLines={3}
              renderTruncatedFooter={this._renderTruncatedFooter}
              renderRevealedFooter={this._renderRevealedFooter}>
          <Text style={[styles.userInfoText,commonStyles.semiBoldText,commonStyles.smallText]}>
            <MarkdownView>{data}</MarkdownView>
          </Text>
        </ReadMore>
        </View> 

If i am giving the height and width the continue reading doesn't work properly.

Is there any way to render it using "rules" property. I am unable to get how to use the "rules" property.

Benjamin-Dobell commented 6 years ago

@pandeyrohit51 You cannot have <MarkdownView> appear inside a <Text> element, this is a limitation of Android & RN, as Android's native TextView does not support nesting. On iOS nesting of regular views in text views can be achieved by providing a fixed width and height to the nested view, however in order to remain cross-platform this is not something actively supported by react-native-markdown-view.

Nonetheless, what you're attempting can be achieved without the <Text> view. You can pass styles directly to <MarkdownView> to style text how you'd like. The supported styles are contained in styles.js.

benschell commented 6 years ago

@Benjamin-Dobell I've just encountered this error when using indented bullet lists, e.g.:

Here's a list:

* Item 1
  * Item 1.1
  * Item 1.2
* Item 2
lukewlms commented 6 years ago

Considering the only repro case provided here is indented list, this is a duplicate of https://github.com/Benjamin-Dobell/react-native-markdown-view/issues/14.

tylerjbainbridge commented 5 years ago

Any update on this? It's crashing our app.

schumannd commented 4 years ago

+1