import { useEffect , useState } from 'react' ; const useCoords = ( location ) => { const { kakao } = window ; const geocoder = new kakao . maps . services . Geocoder ( ) ; const [ geocoderObj , setGeocoderObj ] = useState < any > ( ) ; useEffect ( ( ) => { if ( location === '' || location === undefined || location === null ) { throw new Error ( 'locatio에 해당하는 값이 없습니다.' ) ; } geocoder . addressSearch ( location , ( result ) => { setGeocoderObj ( new kakao . maps . LatLng ( result [ 0 ] . y , result [ 0 ] . x ) ) ; } ) ; } , [ location ] ) ; return geocoderObj ; } ; export default useCoords ;