In React Native, text strings must be rendered within a <Text> component. The <Text> component is part of the core React Native library and does not require any additional packages to be installed. To use the <Text> component, you can import it from the 'react-native' module and then use it like any other React component. For example:
import { Text } from 'react-native'; function MyComponent() { return ( <Text>Hello, world!</Text> ); }
In this example, the text "Hello, world!" will be rendered on the screen inside a
<Text> component.
You can also add styles to text component by passing style prop to it. likeimport { Text } from 'react-native';
function MyComponent() {
return (
<Text style={{color:'blue',fontSize:20}}>Hello, world!</Text>
);
}
This will make the text blue and font size of 20.
0 Comments
Post a Comment