A
A
ajlee42021-01-22 12:06:38
React Native
ajlee4, 2021-01-22 12:06:38

How to avoid problem with onBlur in input when closing screen in React native?

Welcome all. Faced a problem. There is a screen, when switching to it, autofocus on the input is triggered, on which the onBlur event handler hangs, at which a request for backing flies. So the problem is that if I just want to exit this screen and not click anything, then before closing the screen, the focus drops from the input and therefore the onBlur event fires and an unnecessary request flies, how can I avoid this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denioo, 2021-01-28
@Denioo

Just write a crutch through the state, and check if it is empty then do not send a request. Although it is difficult to call it a crutch, in principle, the usual decision is to check for emptiness or change and send it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question