react native get TextInput value

前端 未结 16 2090
一生所求
一生所求 2020-12-04 16:10

I am stuck with a very simple problem. I have login form with username, password and button. In my button handler, I try to get the textinput value. But always get undefined

16条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-04 17:05

    User in the init of class:

    constructor() {
        super()
        this.state = {
            email: ''
        }
    }
    

    Then in some function:

    handleSome = () => { console.log(this.state.email) };

    And in the input:

    this.setState({email})}/>

提交回复
热议问题