From 49d4846376a788f675afbe328e7fad10bf1e64b3 Mon Sep 17 00:00:00 2001 From: Chris Serra <789723+cbserra@users.noreply.github.com> Date: Tue, 22 Aug 2023 06:25:35 -0700 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=9A=A7=20trying=20to=20get=20?= =?UTF-8?q?page=20to=20load=20faster=20for=20screenshot=20tool=20to=20work?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 21 +++++++++++++++------ src/components/header/Header.tsx | 4 ++-- src/components/map/Map.tsx | 4 +++- 3 files changed, 20 insertions(+), 9 deletions(-) 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()