Complete the code to import the core React Native component for displaying text.
import { [1] } from 'react-native';
The Text component is used to display text in React Native apps.
Complete the code to create a simple React Native component that returns a View with a Text inside.
export default function App() {
return (
<[1]>
<Text>Hello!</Text>
</[1]>
);
}The View component is a container for layout and grouping in React Native.
Fix the error in the code by completing the import statement to enable cross-platform components.
import React from 'react'; import { [1] } from 'react-native';
The Platform module helps detect the platform (iOS or Android) to write platform-specific code.
Fill both blanks to create a style object with a background color and padding.
const styles = StyleSheet.create({
container: {
backgroundColor: '[1]',
[2]: 10
}
});The backgroundColor sets the background color, and padding adds space inside the container.
Fill all three blanks to create a cross-platform button with a press handler.
import { Button, Alert } from 'react-native'; export default function App() { const onPressHandler = () => { Alert.alert('[1]'); }; return ( <Button title=[2] onPress=[3] /> ); }
The alert shows a message when the button is pressed. The title is the button text, and onPress is the function called on press.