TEXT AND TEXTINPUT IN REACTNATIVE
In React Native text is used to display text inside screen
It allows text render inside a app various types of textual information is available
Paragraphs, buttons, labels
Example of Text :
import { Text,View, StyleSheet } from ‘react-native’;
const YourComponent = () => {
return(
<View style={styles.container}>
<Text>Hello, Text Is Here</Text>
</View>
);
}
const styles=StyeSheet.create({
container: {
flex:1,
justifyContainer:’center’
alignItem:’center’
},
textStyle: {
fontSize:20
fontWeight:’bold’,
color:’blue’
},
});
export default YourComponent;
TEXTINPUT :
Textinput is used to where user can create a input field, user can also enter text
It is also can be used for edit and type text in app
Example of TextInput
import React, { useState } from ‘react’;
import { View, TextInput, Button, Alert, StyleSheet } from ‘react-native’;
const YourComponent = () => {
const [text, setText] = useState(”);
const handleInputChange = (inputValue) => {
setText(inputValue);
};
const handleButtonPress = () => {
Alert.alert(‘Entered Text’, text);
};
return (
);
}; const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: ‘center’,
alignItems: ‘center’,
padding: 20,
},
input: {
height: 40,
borderWidth: 1,
borderColor: ‘gray’,
paddingHorizontal: 10,
marginBottom: 20,
width: ‘100%’,
},
}); export default YourComponent;