Skip to content
Advertisement

AsyncStorage setItem inside loop crashes

App crashes when trying to save something into asyncStorage. It crashes without an error message however I think the problem is in the while loop:

JavaScript

As soon as the loop gets executed, the app crashes, console.log("got here") doesn’t even run. This function is called from a Pressable component:

JavaScript

Advertisement

Answer

I had to change it from a while loop to a for loop, what I did was the following:

JavaScript

I hope this helps someone who encounters the same issue.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement