Quantcast
Channel: Unfocus a TextInput in React Native - Stack Overflow
Viewing all articles
Browse latest Browse all 13

Answer by Keno Clayton for Unfocus a TextInput in React Native

$
0
0

My use case was a little different. The user wouldn't enter a value directly in the input field. The field was mainly used to capture the user's attempt at entering a value and open a modal instead. I wanted to blur the field after the modal closed to reduce the extra tap the user would have to do later.

If using Hooks, you can do something as simple as

const inputRef = useRef(null);<Input  ref={inputRef}  {...props}/>

Then just call this anywhere you need it.

inputRef.current.blur();

Viewing all articles
Browse latest Browse all 13

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>