Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

168
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda