import { useScript } from "https://deno.land/x/netzo@0.5.70/deps/usehooks-ts.ts";
Custom hook for dynamically loading scripts and tracking their loading status.
Examples
const scriptStatus = useScript('https://example.com/script.js', { removeOnUnmount: true });
// Access the status of the script loading (e.g., 'loading', 'ready', 'error').
const scriptStatus = useScript('https://example.com/script.js', { removeOnUnmount: true }); // Access the status of the script loading (e.g., 'loading', 'ready', 'error').
Parameters
- The source URL of the script to load. Set to
null
or omit to prevent loading (optional).
optional
options: UseScriptOptions- Additional options for controlling script loading (optional).
Returns
The status of the script loading, which can be one of 'idle', 'loading', 'ready', or 'error'.