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

后端 未结 4 2082
生来不讨喜
生来不讨喜 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:09

    Simple solution: This way onBlur your state's email will always have the last value changed by the user.

               validate = () => {
                const { email } = this.state
                console.log('Validating Email Here!', email)
               }
    
               this.setState({email})}
               onBlur={e => this.validate()}
             />
    

提交回复
热议问题