I am getting the latitude and longitude from a Use Effect hook (which I am relatively new to). I want to return the values outside the use effect hook and store them in variables or even state if needed. I can console log the values but do i just add a return statement or pass arguments somehow? What feature do i need to make use of? I plan to pass the lat and long data into other parts of code which is why i am trying to retrieve it from the useEffect hook.
useEffect(() => {
if ("geolocation" in navigator) {
console.log("Available");
} else {
console.log("Not Available");
}
navigator.geolocation.getCurrentPosition(function (position) {
let lat = position.coords.latitude;
let long = position.coords.longitude;
console.log(lat);
console.log(long);
});
}, []);
let newLat = lat?
let newLong = long?