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

165
Vistas
Next.js script render

In my Next.js project I have a script that renders a widget as follows:

      <a
        className="e-widget no-button xdga generic-loader"
        href="https://example"
        rel="nofollow"
      >
        3 lucky winners stand a chance to win…
      </a>
      <Script
        type="text/javascript"
        src="https://widget.gleamjs.io/e.js"
        strategy="afterInteractive"
      ></Script>

The problem is that once this script executes on the initial render, it does not execute again later.

Anyone know how I can get the script to execute multiple times?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

The issue might be originating from other parts but you can give this a shot:

import React, { FC } from "react";
import Script from "next/script";

interface Props {
  id: string;
}

const Widget: FC<Props> = ({ id }) => {
  return (
    <>
      <a
        className="e-widget no-button xdga generic-loader"
        href="https://example"
        rel="nofollow"
      >
        3 lucky winners stand a chance to win…
      </a>
      <Script
        id={id}
        src="https://widget.gleamjs.io/e.js"
        strategy="afterInteractive"
      />
    </>
  );
};

export default Widget;
about 4 years ago · Juan Pablo Isaza Denunciar

0

I managed to solve the problem by forcing the parent component to re-mount, which then causes my Script tag to re execute/render as desired.

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