Skip to content

Latest commit

 

History

History

use-script

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

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 (
        ...
    );
}