React State Not Updating on Android

React State Not Updating on Android
0.0 0

#1

Hi everyone!

I’m working on my Local Weather app in the front end portion of the courses. I decided to use React as I’ve seen a lot of very positive reviews about it and also many job postings listing it as a desired skill. Everything is working well in my desktop environment with states loading and reloading as expected. However, when I load the same app on my Android phone (a OnePlus2) I get the initial page load with my React components, but once the data is returned from the APIs (at least I think it’s returned from the APIs) React does not update the states. For reference, my app is in a testing environment at

https://local-weather-kylemckenzie.c9users.io/.

It may go up and down a bit as I’m still making changes, so if you do take time to look at it and find it offline, please send me a message and I’ll get the server restarted ASAP.

Thank you!

Kyle


#2

I think it may be because you’re not allowing Android to track your current location.


#3

Good suggestion, I just checked to make sure I did have it enabled on both the Chrome browser and the OS and did. I still get no state update.


#4

Further thoughts, I’m using navigator.getCurrentPosition() in the background. I think that may be failing quietly in the background preventing the subsequent API calls.


#5

Try with the answer provided http://stackoverflow.com/questions/18100442/samsung-galaxy-devices-cant-use-geolocation-getcurrentposition


#6

Thank you Oxyrus, I appreciate your help!

I ended up avoiding the use of navigator.geolocation.getCurrentPosition() because of too many issues with various phones and used one of the many IP geolocation APIs available. Initially I was worried the additional request would add time and overhead to the apps render time, but my render time actually decreased by switching to the API call (I must have written something awfully inefficient!).