Skip to content

Files

Latest commit

88abf62 · May 28, 2024

History

History

use-script

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
May 28, 2024
May 12, 2022

useScript

The useScript hook allows you to load dynamic script tags on the page from within your react application. This is useful for things like form / video embeds where the script url may include a specific identifier.

Usage

function BlockEdit( props ) {
    const { attributes } = props;
    const { formId } = attributes;

    const { hasLoaded, scriptElement } = useScript( `https://example.com/${formId}` );

    return (
        ...
    );
}