如何知道焦点何时在反应本机 textInput 中丢失?

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

如何知道焦点何时在反应本机文本输入中丢失?

例如,我想在用户触摸 textInput 外部并失去焦点时执行一个操作。

您要找的道具是onBlur。当它失去焦点时调用它。

TextInput

上使用 onBlur 道具

示例

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

Docs

您需要在 TextInput 上使用 onBlur 属性。

例子

onBlurMethod = () =>{
   //what you want to do when it is not focused

}

<TextInput
         onBlur = {this.onBlurMethod}
/>