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

224
Visualizações
How I dynamically add and load an external script in react

I am trying to render a script tag from a react component, I have tried to manually create script tag element but it does not load the .js I am trying to display a widget. For now I have included it into the main index.html file. Is that the only method or am I missing something.

PS:-I cant test the api anymore as I have consumed all my daily requests

I have looked into the script js tag it targets elements by getElementbyid function but nothing renders on my page

import { React, useEffect, useState } from "react";

const Upcoming_matches = () => {
  return (
    <>
      <div
        id="wg-api-football-fixtures"
        data-host="v3.football.api-sports.io"
        data-refresh="60"
        data-date="2022-02-11"
        data-key="xxx-xxx-xxx"
        data-theme="dark"
        data-show-errors="true"
        className="api_football_loader"
      ></div>
    </>
  );
};

export default Upcoming_matches;
 

the script tag

<script
      type="module"
      src="https://widgets.api-sports.io/football/1.1.8/widget.js">
  </script>
about 4 years ago · Juan Pablo Isaza
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