React Native - Get Text Input Value | Handling Text Input
App.Js: -
import React, { useState } from 'react';
import { Text, Button, View, StyleSheet, TextInput } from 'react-native';
const App = () => {
const [name, setName]=useState("");
return (
<View>
<Text style={{fontSize:30}}>Handle Text Input</Text>
<Text style={{fontSize:30}}>Your Name is = : {name}</Text>
<TextInput style={styles.textInput} placeholder='Enter Name' value={name} onChangeText={(text)=>setName(text)}/>
<Button title='Clear Text' onPress={()=>setName('')}/>
</View>
);
};
const styles=StyleSheet.create({
textInput:{
borderWidth:2,
borderColor:'blue',
color:'blue'
}
})
export default App;
Comments
Post a Comment