I've been struggling with a Picker item which refreshes too many times when changing it's value. The element is used for changing Settings in the app and storing it in the internal storage thanks to AsyncStorage
.
I'm using createContext
and my functions in StorageContext
take care of the retrieving and saving of the setting.
I've made a repro here.
Changing the options work fine but if you look carefully, it updates too many times. For instance if the user changes from time1
to time2
, the picker value will do:
time1
> time2
> time1
> time2
On Snack and my mobile it's almost not visible but in the Android simulators it is more... That means my implementation is not the best. This is also confirmed by looking at the console.
How can I improve my code so it works better? Feel free to change the code directly here.
The relevant code is in Settings.js
and StorageContext.js