Currently, weather API calls should in theory be throttled to no more than 1 per second. However, this doesn't work if Context gets stuck in an infinite re-render loop where lastWeatherFetchTime's initial zero value is preserved in a stale closure. This can result in 100's of calls per second.
To fix, store lastWeatherFetchTime in local storage instead. This will make sure the timestamp is always preserved between renders, and even between page reloads.
Currently, weather API calls should in theory be throttled to no more than 1 per second. However, this doesn't work if
Context
gets stuck in an infinite re-render loop wherelastWeatherFetchTime
's initial zero value is preserved in a stale closure. This can result in 100's of calls per second.To fix, store
lastWeatherFetchTime
in local storage instead. This will make sure the timestamp is always preserved between renders, and even between page reloads.