When a API call is happening, Im not able to click any touchables in the screen. They wont respond until the API call is done. Is there any solution for this?
I tried with many react native components like TouchableOpacity, TouchableHighlight, Pressable but the main issue is onPress itself is not trigger when the API call is in process.
2
Answers
You must use
async
/await
or.then
while making api calls. if you are not using these your app will stop working until api call completes or promise resolves.Can you open the dev tool and set
show perf monitor
on and check the JS FPS?Async functions usually don’t block touchables while they are running in the background. Regardless if you use
async/await
or.then
.According to what you have provided, it seems that your JS thread is freezing which means there are many processes running in the background.
Can you please share a snippet of the code you are running?