import { useState } from "react";

export const useLoadScript = (src:string,scriptId:string) => {
    const [loaded, setLoaded] = useState(false);
      const existingScript = document.getElementById('googleMaps');
      if (!existingScript) {
        const script = document.createElement('script');
        script.src = src;
        script.id = scriptId;
        document.body.appendChild(script);
        script.onload = () => {
          setLoaded(true);
        };
      }
      if (existingScript) setLoaded(true);
  
      return {loaded}
  }
  
  