Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default hardbreak breaks on Android #60

Open
mazharmorshed opened this issue Jun 20, 2018 · 3 comments
Open

Default hardbreak breaks on Android #60

mazharmorshed opened this issue Jun 20, 2018 · 3 comments

Comments

@mazharmorshed
Copy link

mazharmorshed commented Jun 20, 2018

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 facebook/react-native#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>,
),
@mazharmorshed mazharmorshed changed the title Hardbreak within Text breaks on Android Default hardbreak breaks on Android Jun 20, 2018
@mientjan
Copy link
Owner

mientjan commented Jun 20, 2018

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.

@mazharmorshed
Copy link
Author

mazharmorshed commented Jun 24, 2018

@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:

  • hardbreak needs to either split Text components on the most outer level and implement the hardbreak View between the Text paragraphs,
  • 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.

@toml0006
Copy link

toml0006 commented Aug 3, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants