How do you get elements in react-native?
My use-case is a login screen. the submit button is pressed and now i want to get the value of username and password TextInputs.
export default class Login extends Component
{
login()
{
//document.getElementById('username'); //run-time error
}
render()
{
return (
<View style={{flex: 1,flexDirection: 'column',justifyContent: 'space-between',margin:10}}>
<View style={{backgroundColor: 'powderblue'}} />
<MyTextField id='user' placeholder="User Name" />
<MyTextField id='pass' placeholder="Password" />
<MyButton onPress={this.login} title='Login'/>
</View>
);
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…