import React, { useState, useEffect } from "react"; function Coordinates({ latitude, longitude }) { const [smallScreen, setSmallScreen] = useState(false); useEffect(() => { if (window.screen.width < 480) setSmallScreen(true); else setSmallScreen(false); // eslint-disable-next-line react-hooks/exhaustive-deps }, [window.screen.width]); return (
Latitude: {smallScreen ? latitude.slice(0, 7) : latitude}
Longitude: {smallScreen ? longitude.slice(0, 7) : longitude}
); } export default Coordinates;