title: How to return values from UseEffect Hook
body: <p>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.</p>
  <pre><code>useEffect(() =&gt; {
      if (&quot;geolocation&quot; in navigator) {
        console.log(&quot;Available&quot;);
      } else {
        console.log(&quot;Not Available&quot;);
      }
      navigator.geolocation.getCurrentPosition(function (position) {
        let lat = position.coords.latitude;
        let long = position.coords.longitude;
        console.log(lat);
        console.log(long);
      });
    }, []);
  </code></pre>
  <pre><code>let newLat = lat?
  let newLong = long?
  </code></pre>