Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!