How do I get the value in TextInput when onBlur is called?

后端 未结 4 2064
生来不讨喜
生来不讨喜 2020-12-29 05:48

In React native, I want to pass the value of the TextInput in the onBlur event handler.

onBlur={(e) => this.validateText(e.target.value)}
<
4条回答
  •  感情败类
    2020-12-29 06:06

    You should use the 'onEndEditing' method instead of the 'onBlur'

    onEndEditing?: function Callback that is called when text input ends.

    onBlur is a component function where onEndEditing is specific for TextInput

    onEndEditing

    This approach works for both multiline and single line.

     
        {
            this.setState({textValue: e.nativeEvent.text})
        }
    }/>
    

提交回复
热议问题