title: Geolocation through React-Redux
body: <p>I am trying to get a better understanding of redux and react lifecycle method.</p>
  
  <p>I have a prop function on component did mount that calls a function in redux. On redux I am calling the location to get the position and setting the initial state and updating it when the call gets made. I am able to get the position but no matter what I've tried through redux, my coords(initial state) still comes out as undefined. I tried a .then() on the componentDidMount function and set state locally and this worked. But I would like to use this feature with redux to try and get a better understanding of it. My understanding is that as long as there is an initial state, there should not be a problem in updating it. But I feel that my problem may be somewhere with my action.payload. As it is not logging anything in my switch case for GET_LOCATION. One thing of note, i get a yellow warning on my console, '[Violation] Only request geolocation information in response to a user gesture.' I am not sure if this impacts anything. Anyways, any suggestions would be vastly appreciated. I've searched high and low for a nice solution to geolocation through redux. Here is the code:</p>
  
  <pre><code>const initialState = {
      coords: { }
  };
  
  
  export function getLocation() {
      const geolocation = navigator.geolocation;
            return {
               type: GET_LOCATION,
               payload: geolocation.getCurrentPosition((position) =&gt; {
                   console.log(position.coords)
                   return position
               })
           }
  
  };
  </code></pre>
  
  <p>Switch Statement:</p>
  
  <pre><code>case GET_LOCATION:
      console.log(GET_LOCATION)
          return Object.assign({},
              state,
              {
                  coords: action.payload
              }
          )
  </code></pre>