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

152
Vistas
Rendering math tags in React using Wiris MathML script

I try to display MathML using Wiris plugin. Loading the script it renders math tags but when you dynamically add new ones, they are not rendered.

Math.js

import { Helmet } from "react-helmet";

function Math(params) {
  const mString =
    `<p><strong>What is the result ?</strong></p><p>` +
    `<math xmlns="http://www.w3.org/1998/Math/MathML"><mroot><mn>27</mn><mn>3</mn></mroot><mo>&nbsp;</mo><mo>+</mo><mo>&nbsp;</mo><mfrac>` +
    `<mn>9</mn><mn>3</mn></mfrac></math></p>`;

  return (
    <div>
      {" "}
      <Helmet>
        <script
          src="https://www.wiris.net/demo/plugins/app/WIRISplugins.js?viewer=image&async=true"
          type="text/javascript"
        />
      </Helmet>
      <div id="htmlParser" dangerouslySetInnerHTML={{ __html: mString }}></div>
    </div>
  );
}

export default Math;

App.js

import { useEffect, useState } from "react";
import Button from "@material-ui/core/Button";
import Math from "./Math";

function Home() {
  const [counter, setCounter] = useState(3);

  const handleIncrease = () => {
    setCounter(counter + 1);
  };

  return (
    <div>
      <Button
        variant="outlined"
        color="primary"
        onClick={handleIncrease}
        style={{ marginInline: 12 }}
      >
        Add
      </Button>
      {[...Array(counter)].map((el, index) => (
        <Math />
      ))}
    </div>
  );
}

export default Home;

The items which rendered first are displayed properly. But when you add new one, they are not affected.

It doesn't change the result if I add the script as below instead of react-helmet:

useEffect(() => {
        const script = document.createElement('script');
        script.type = 'text/javascript';
        script.src = 'https://www.wiris.net/demo/plugins/app/WIRISplugins.js?viewer=image&async=true';
        document.head.appendChild(script);
    return () => {
        document.head.removeChild(script);
    };
}, []);

enter image description here

How could I render them all properly in my react app ?

about 4 years ago · Juan Pablo Isaza
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