diff --git a/src/App.tsx b/src/App.tsx index d4c6e2d..cdff613 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -7,12 +7,12 @@ import { SearchKeyType } from './types/FormValidationTypes' function App() { const [inputSearchValue, setInputSearchValue] = useState() - const [latLng, setLatLng] = useState([]) + const [latLng, setLatLng] = useState([0, 0]) const useAxios = getIpifyUseAxios() const [{ data, loading, error }, refetch] = useAxios({}) useEffect(() => { - if (data) { + if (data?.location) { console.debug('🚀 ~ file: App.tsx ~ line 63 ~ useEffect ~ data', data) setLatLng([data.location.lat, data.location.lng]) } @@ -20,7 +20,7 @@ function App() { return ( <> - {data && ( + {/* {data && (
- )} - - {latLng.length === 2 && } + )} */} +
+ {/* {latLng.length === 2 && } */} + ) } diff --git a/src/components/header/Header.tsx b/src/components/header/Header.tsx index ebfd976..eef914c 100644 --- a/src/components/header/Header.tsx +++ b/src/components/header/Header.tsx @@ -28,7 +28,7 @@ const Header = (props: { return (
IP Address Tracker
diff --git a/src/components/map/Map.tsx b/src/components/map/Map.tsx index 7f5c2f1..9f22309 100644 --- a/src/components/map/Map.tsx +++ b/src/components/map/Map.tsx @@ -7,7 +7,9 @@ import 'leaflet/dist/leaflet.css' import { Map as LeafletMap, Marker as LeafletMarker } from 'leaflet' const Map = (props: { latLng: number[] }) => { - const [latLong, setLatLong] = useState(L.latLng(props.latLng[0], props.latLng[1])) + const [latLong, setLatLong] = useState( + L.latLng(props.latLng[0] || 0, props.latLng[1] || 0) + ) const mapRef = useRef() const markerRef = useRef()