Here I want to assign the data from textInput to variable a. How can I do it? (That is, when the user enters data in textInput, I want to assign it to variable a.)
import React, { Component } from 'react' import { Text, View, TextInput} from 'react-native' export default class deneme1 extends Component { constructor(props) { super(props); this.state = { a:"", }; } render() { return ( <View> <View style={styles.textinput}> <TextInput placeholderTextColor='white' style={styles.textinputtext} /> </View> </View> ) } }
You can try this one
<TextInput
placeholder={"A Variable"}
onChangeText={(text) => this.setState({a: text}) }
value={this.state.a}
/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.