Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

How to know when the focus is lost in a react native textInput?

Writer Sophia Terry

How to know when the focus is lost in a react native textInput?

For example I want to do an action when the user touches outside the textInput and it loses focus.

0

3 Answers

use the onBlur prop on TextInput

example

<TextInput onFocus={() =>console.log("focus received" ) } onBlur={() => console.log("focus lost") } />

Docs

The prop you are looking for is the onBlur. This is called when it loses focus.

You need to use the onBlur prop on TextInput.

example

onBlurMethod = () =>{ //what you want to do when it is not focused
}
<TextInput onBlur = {this.onBlurMethod}
/>

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy