Skip to content
Advertisement

React Native TextInput sends input on second press

Guys i’m new to React Native and also not good at JavaScript. In my app i have 2 TextInput and a Pressable button but the output is not making sense. I’ve tried to change timing of execution of some lines but result is the same.

I’m using: expo, react native 0.68.2, android api 30 (Android Studio)

output:

Android Bundling complete 32ms

First click

LOG description :

LOG identity :

Second click

LOG description :sadasdas

LOG identity :12345678910


Report.js

JavaScript

Advertisement

Answer

Try something like that instead :

JavaScript

The useEffect should be triggered twice since both description and identity are in the dependency array but it’s a good start to manage the asynchronous behavior of useState.

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