What are Touchable Interactions in React Native?
What are Touchable Interactions in React Native?
Touchable interactions in React Native refer to the various ways users can interact with elements on the screen through touch gestures. React Native provides several components specifically designed to handle these touch interactions, allowing developers to create responsive and interactive user interfaces. The primary touchable components in React Native include:
TouchableOpacity:
import React from 'react';
import { TouchableOpacity, Text } from 'react-native';
const App = () => (
<TouchableOpacity onPress={() => console.log('Pressed')}>
<Text>Click Me</Text>
</TouchableOpacity>
);
export default App;
activeOpacity
, onPress
, style
, etc.[1][2][3][13]TouchableHighlight:
TouchableOpacity
.import React from 'react';
import { TouchableHighlight, Text } from 'react-native';
const App = () => (
<TouchableHighlight underlayColor="#DDDDDD" onPress={() => alert('Pressed')}>
<Text>Press Me</Text>
</TouchableHighlight>
);
export default App;
underlayColor
, onPress
, style
, etc.[1][2][3]TouchableWithoutFeedback:
import React from 'react';
import { TouchableWithoutFeedback, View, Text } from 'react-native';
const App = () => (
<TouchableWithoutFeedback onPress={() => console.log('Pressed')}>
<View>
<Text>Press Me</Text>
</View>
</TouchableWithoutFeedback>
);
export default App;
onPress
, style
, etc.[2][3][6]TouchableNativeFeedback:
import React from 'react';
import { TouchableNativeFeedback, View, Text } from 'react-native';
const App = () => (
<TouchableNativeFeedback onPress={() => console.log('Pressed')}>...
middle
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào