Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

120
Vistas
How to render HTML tags in REACT NATIVE

I want to show news in my react native application but the content from API is in HTML. So, Please can you tell me how to render HTML without any library.

  "content": "<ul><li>Bitcoin, in terms of market value, rose 4.6% to $53,859.6.</li><li>It passed $50,000 mark for first time in four weeks on Tuesday. </li><li>Bitcoin fell below $50,000 in early September.</li>"
    
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Without library you can render HTML using dangerouslySetInnerHTML:

<div dangerouslySetInnerHTML={{ __html: response.content }}></div>

However, this is not recommended, because it may be used for a cross-site scripting (XSS) attack

about 4 years ago · Juan Pablo Isaza Denunciar

0

const yourDataObject = {
    "content": "<ul><li>Bitcoin, in terms of market value, rose 4.6% to $53,859.6.</li><li>It passed $50,000 mark for first time in four weeks on Tuesday. </li><li>Bitcoin fell below $50,000 in early September.</li>"
}

const area = document.getElementById("area")
area.innerHTML = yourDataObject.content;
<div id="area"></div>

Decide where you want to render your HTML. In the example below I am going to render the content into the div tag that has an id attribute of "area".

<div id="area"></div>

In your JavaScript, you can select the element with document.getElemenyById and pass in the id attribute value. Next target the innerHtml of the selected div element and set it to be your content.

const yourDataObject = {
    "content": "<ul><li>Bitcoin, in terms of market value, rose 4.6% to $53,859.6.</li><li>It passed $50,000 mark for first time in four weeks on Tuesday. </li><li>Bitcoin fell below $50,000 in early September.</li>"
}

const area = document.getElementById("area")
area.innerHTML = yourDataObject.content;

Note

Always be sure you trust the source of the HTML you are choosing to render in your site. If you do not control the source it is possible that you could render malicious code into your site.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda