title: navigator.geolocation.getCurrentPosition function results in undefined when called outside local scope
body: <p>How can I access the object of the navigator.geolocation.getCurrentPosition success callback outside the function when calling it?</p>
  
  <p>Let say I have a function in a file(called UserLoc) which I am exporting.</p>
  
  <pre><code>export const locateCurrentPosition = () =&gt; {
    const currentPosition = navigator.geolocation.getCurrentPosition(
      position =&gt; {
        console.log(position);
        return position;
      },
      error =&gt; {
        console.log(error.message);
        return error;
      },
      {
        enableHighAccuracy: true,
        timeout: 10000,
        maximumAge: 1000
      }
    );
  
    return currentPosition;
  };
  </code></pre>
  
  <p>Now on one of my component js files, I want to call this function inside the componentDidMount()</p>
  
  <pre><code>const {
    locateCurrentPosition
  } = require("../Views/components/User/UserMap/UserLoc");
  
  async componentDidMount(){
  
  console.log(locateCurrentPosition())
  locateCurrentPosition().then(data=&gt;console.log(data))
  }
  </code></pre>
  
  <p>When I am calling the function inside my componentDidMount, it always returns an undefined.  When Im logging this, it prints out the position when inside the local scope (ie first code block above where I use console.log(position).  What is the best way to actually retrieve the position object from a successful callback and return it into my componentDidMount when called?  </p>
  
  <p>Ive tried promises, then statements with my console log as well as different types of returns, but I always seem to get undefined.  The return statements within the locateCurrentPosition function dont seem to work.  Any suggestions?</p>