import { useRef, useState } from 'react'; import { useAsyncEffect } from '../../../utils'; import { MapApi } from '../../data/map.api'; export const useMapConfigurer = (key: string, geocodeKey: string) => { const [isConfigured, setIsConfigured] = useState( MapApi.shared.getInitStatus() ); const _conf = useRef(isConfigured); useAsyncEffect(async () => { if (!_conf.current) { await MapApi.shared.init(key, geocodeKey); _conf.current = true; setIsConfigured(true); } }, []); return { isConfigured, }; };