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

Custom renderer wrapper property being ignored #276

Closed
tomdaniel-it opened this issue Jul 22, 2019 · 1 comment
Closed

Custom renderer wrapper property being ignored #276

tomdaniel-it opened this issue Jul 22, 2019 · 1 comment
Labels
bug:easyfix Easily fixed. bug Crush'em all. is:waiting pr A pull request is awaiting reviews to solve the problem.

Comments

@tomdaniel-it
Copy link

Is this a bug report or a feature request?

Bug report

Have you read the guidelines regarding bug report?

Yes

Have you read the documentation in its entirety?

Yes

Have you made sure that your issue hasn't already been reported/solved?

Yes

Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?

Both

Is the bug reproducible in a production environment (not a debug one)?

Yes

Have you been able to reproduce the bug in the provided example?

Yes

Environment

Not environment specific

Steps to Reproduce

  1. Add a html string to be given to the HTML component with a tag included in the TEXT_TAGS array (<span></span> for example)
  2. Add a custom renderer, including a renderer for the span tag which returns a View component with anything inside
  3. Add a custom wrapper to the custom renderer for the span tag, which is wrapper: 'View'

Expected Behavior

Because span is in the list of TEXT_TAGS, it gets wrapped by a Text component by default. Since we are using a View in the custom renderer, this can not happen since Text's in View's throw errors. The custom wrapper with value 'View' will make sure it is wrapped with a View component instead.

Actual Behavior

The mapDOMNodesTORNElements function maps each DOMNode, setting a wrapper property at the end with a value of 'View' or 'Text'. This is done with an if-else structure:

  • 1: if (children need a view)
    • then: set wrapper to 'View'
  • 2: else if (tagname (span) is present in the array of TEXT_TAGS or MIXED_TAGS)
    • then: set wrapper to 'Text'
  • 3: else if (custom renderer is present and this renderer has a wrapper property)
    • then: set wrapper to the wrapper property of the custom renderer

The tagname span is present in TEXT_TAGS, making the wrapper having the value 'Text'. This makes it that our View's (defined in custom renderer for span tag) are wrapped with a Text component, crashing the application.

The order of the if statements should be 3, 1, 2, giving custom properties priority over the default properties.

Reproducible Demo

https://snack.expo.io/@tomdaniel-it/react-native-render-html-bug

@jsamr jsamr added bug Crush'em all. bug:easyfix Easily fixed. is:waiting pr A pull request is awaiting reviews to solve the problem. labels Jul 4, 2020
@jsamr jsamr closed this as completed in 245be04 Jul 23, 2020
@jsamr
Copy link
Collaborator

jsamr commented Jul 25, 2020

The fix has been backported to v4.2.3-beta.1. See the instructions to test and report here #390!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:easyfix Easily fixed. bug Crush'em all. is:waiting pr A pull request is awaiting reviews to solve the problem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants