Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

usescript +react

import * as React from "react";

function loadError(onError) {
  console.error(`Failed ${onError.target.src} didn't load correctly`);
}

function External() {
  React.useEffect(() => {
    const LoadExternalScript = () => {
      const externalScript = document.createElement("script");
      externalScript.onerror = loadError;
      externalScript.id = "external";
      externalScript.async = true;
      externalScript.type = "text/javascript";
      externalScript.setAttribute("crossorigin", "anonymous");
      document.body.appendChild(externalScript);
      externalScript.src = `https://externalurl.example.com/external.js?key=9393ABCDEFGH`;
    };
    LoadExternalScript();
  }, []);

  return <></>;
}

export default External;
Comment

PREVIOUS NEXT
Code Example
Javascript :: tictactoe using Jquery 
Javascript :: Search specific products in the array in javascript 
Javascript :: numbers Math 
Javascript :: javascript unique id generator 
Javascript :: tabindex 
Javascript :: Kontol Javascript 
Javascript :: Working with substring 
Javascript :: google distance value to km convert 
Javascript :: react modal scroll 2 overlapping components 
Javascript :: Reactjs exemple function component 
Javascript :: how to show conditional show on select field 
Javascript :: react native getting old navigation parameter 
Javascript :: jquery database add dropdown in datababe grid 
Javascript :: full screen window open and disable all apps by javascript 
Javascript :: Schalte das jQuery Migrate Script ab 
Javascript :: return asynchronous result and not undefined 
Javascript :: If Presence Shorthand javascript 
Javascript :: error while updating linecap of a view polyline react-native-maps 
Javascript :: array min value in vmware_vro 
Javascript :: window.print specific div 
Javascript :: convert online code javascript to python 
Javascript :: downlaod file from website raect 
Javascript :: react native navigation export 
Javascript :: check trigger is human jquery 
Javascript :: javascript grow function 
Javascript :: change class on resize window jquery 
Javascript :: how to change default browser in vs code json 
Javascript :: setinterval clearinterval querySelector until render 
Javascript :: javascript is even 
Javascript :: Implicit returns in ES6 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =