title: setState not working in componentDidMount
body: <p>I am getting the user's location in componentDidMount, and it works well. However, after that, I am trying to change the state, and it does not register the change. Here is my constructor:</p>
  
  <pre><code>constructor(props){
   super(props);
   this.locationRetrieved = this.locationRetrieved.bind(this);
   this.state = {
   latitude: 30,
   longitude: 30
   }
  }
  </code></pre>
  
  <p>and my locationRetreived function (hardcoding these for now):</p>
  
  <pre><code>locationRetrieved() {
  this.setState({
    latitude: 78,
    longitude: 89
   });
  }
  </code></pre>
  
  <p>and my componentDidMount:</p>
  
  <pre><code>   componentDidMount() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(success) { 
    this.locationRetrieved();
   },
    function(failure) {
      alert(failure);
      if(failure.message.indexOf("Only secure origins are allowed") == 0)   {
        // Secure Origin issue.
      }
    }); 
  }
   else{
     alert("gelocation is not supported here");
    }
  }
  </code></pre>
  
  <p>I have also tried directly setting state and not calling a function, like:</p>
  
  <pre><code> if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(success) { 
    this.setState({
      latitude: 45,
      longitude: 45
   })
  </code></pre>
  
  <p>},</p>
  
  <p>but that does not work either. I know a location is retrieved, because when I do alert(success.coords.latitude) then the alert with my current latitude shows up. </p>
  
  <p>The error console says:</p>
  
  <pre><code> Uncaught TypeError: Cannot read property 'locationRetrieved' of undefined
  at eval (eval at ./app/containers/CheckIn/index.js 
  </code></pre>
  
  <p>How can I set the state here once latitude/longitude are retrieved?</p>
  
  <p>Thanks</p>