Skip to content
Advertisement

How to avoid re rendering text input?

I have a TextInput and I don’t want it to re render every time I change the value inside it

JavaScript

but I want to be able to change the value inside the input at the push of a button that’s why I haven’t just used defaultValue

any solutions??

Advertisement

Answer

You can use useRef to save text from text input without render , and useState to show text in input on button press:

Live example : https://snack.expo.dev/TW-fMx1-2

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