import React from 'react'; import { View, Button, Pressable, Text } from 'react-native'; export default function App() { return ( <View> {/* Component here */} </View> ); }
Option C uses Pressable with an onPress prop and a Text child, so tapping triggers the alert.
Option A is a Button with onPress, and Button requires a title prop, which is correct here, so it also triggers onPress. But Button is less customizable than Pressable.
Option B lacks onPress, so no tap response.
Option D is a Button without onPress, so no tap response.
Between A and C, both trigger onPress, but C is the best example of Pressable usage.
import React from 'react'; import { Pressable, Text } from 'react-native'; export default function App() { return ( <Pressable onPressIn={() => console.log('Pressed In')} onPressOut={() => console.log('Pressed Out')} onPress={() => console.log('Pressed')} > <Text>Tap me</Text> </Pressable> ); }
When the user touches down, onPressIn fires first.
When the finger lifts, onPressOut fires.
Finally, if it was a valid tap, onPress fires.
import React from 'react'; import { Button } from 'react-native'; export default function App() { return ( <Button title='Press me' onPress={() => alert('Pressed!')} /> ); }
Option A is missing the closing quote for the onPress attribute, causing a syntax error.
Options B, C, and D are syntactically correct ways to use Button.
import React from 'react'; import { Pressable, Text } from 'react-native'; export default function App() { return ( <Pressable> <Text>Tap me</Text> </Pressable> ); }
The Pressable itself has no onPress prop.
Pressable only responds to taps if it has an onPress prop.
Text without onPress does not respond either.
Pressable is a low-level component that lets developers customize how the component looks and behaves on touch events.
Button is a higher-level component with limited styling options.
Option B is false; both support multiple platforms.
Option B is false; accessibility props must be added manually.
Option B is false; Button can be used anywhere.