import { useEffect } from 'react' ; private param id param src param callback export const useExternalScript = ( id , src , callback ) => { useEffect ( ( ) => { const isLoaded = Boolean ( document . getElementById ( id ) ) ; if ( isLoaded ) return ; const script = document . createElement ( 'script' ) ; script . src = src ; script . id = id ; document . body . appendChild ( script ) ; if ( callback ) script . onload = callback ; if ( isLoaded && callback ) callback ( ) ; } , [ ] ) ; } ;