React-native-render-html: Accessing rendered HTML in custom renderers

Created on 2 Oct 2018  路  11Comments  路  Source: meliorence/react-native-render-html

Relates to #43. I'm looking to access the raw HTML of a table inside a custom renderer. The renderer is set up, but I want to find a good way to extract the relevant html.

Looking at the parameters, htmlAttribs and convertedCSSStyles are empty objects as expected, while passProps.html is the entire html document.

Children is the subchildren I'm looking for, but is already pre-processed into react native elements.

Is there a way to get the raw html contained by the rendered tag at this stage in the rendering process?

new feature

Most helpful comment

It is possible to get the actual HTML string in custom renderers so we could use that in a WebView?

All 11 comments

Did you solve it?

No, it appears that by that point, the html is already gone, converted into elements structures.
Came up with a more "react native" solution to my problem, see #43 for details

We are experiencing the same problem - is there a PR for this already?

No, sorry, I think it's simply not supported. If you look at the problem you're trying to solve at a higher level, you can do quite a lot with "alterData", "alterChildren", "render", and "onParsed", thoguh.

The expectation is that children contains something - it looks like that is fixable.

Children does contain something though, it contains the rendered React-Native ready elements, just not XML.

I'm not sure what's your need, but node.children holds child nodes as htmlparser2 objects at: "alterNode", "alterData", "alterChildren" callbacks

It is possible to get the actual HTML string in custom renderers so we could use that in a WebView?

@abhimanyuPathania : Have you find way to get html of specific node in custom renderer?

@jariwalabhavesh No. I ended up not using this package because of that.

This feature has been available since the v5 release. Just use domNodeToHTMLString exported utility over 'domNode(inpassProps`).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aiavci picture aiavci  路  3Comments

xipgroc picture xipgroc  路  6Comments

gabriel-tentaculo picture gabriel-tentaculo  路  7Comments

chadmorrow picture chadmorrow  路  7Comments

KimJeonghun91 picture KimJeonghun91  路  4Comments