@tremendous/help
    Preparing search index...

    Function useScriptLoader

    • Dinamically add a script tag to the document body

      Parameters

      • options: ScriptLoaderOptions = {}

        URL & onLoad callback. If URL is not provided, the script will not be loaded.

      Returns void

      @group: Hooks

      useScriptLoader({ url: "https://example.com/script.js", onLoad: () => console.log("Script loaded!") });

      useScriptLoader({ url: "", onLoad: () => console.log("This won't be called") }); // No script will be loaded

      useScriptLoader({ url: props.url, onLoad: () => console.log("Script loaded") });
      // The script will be added and the previous one will be removed every time the URL changes