0

I have a React Native app which is receiving an HTML file from the backend. This is the content of the HTML file:

<html>
  <head>
    <style>
      #wrapper {
        // styling
      }
      .child {
        // styling
      }
      #img {
        // styling
      }
      #desc {
        // styling
      }
    </style>
  </head>

  <body>
    <div id="wrapper">
      <div id="img" class="child"></div>
      <div id="desc" class="child"></div>
    </div>
  </body>

  <script>
    const img = document.getElementById("img");

    img.addEventListener("click", () => {
      // logic
    });
  </script>
</html>

I just want to display this HTML in a react-native view along with both it's style as well script tag.

2 Answers 2

1

you should use some sort of prebuilt library for that...

here's the one I found really useful => https://github.com/archriss/react-native-render-html

Sign up to request clarification or add additional context in comments.

1 Comment

HI, I don't find any way that I can pass script along with HTML, as you can I'm doing DOM manipulation.
0

I used React-native-render-html library to render html and it works great versatile and very easy to use, you can het it from

https://www.npmjs.com/package/react-native-render-html

1 Comment

HI, I don't find any way that I can pass script along with HTML, as you can I'm doing DOM manipulation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.