MENU
<TouchableNativeFeedback>
This is a wrapper for making views respond properly to touches on Android.
Props(inherits TouchableWithoutFeedback)backgrounduseForegroundhasTVPreferredFocus AndroidnextFocusDown AndroidnextFocusForward AndroidnextFocusLeft AndroidnextFocusRight AndroidnextFocusUp Android | MethodsSelectableBackground()SelectableBackgroundBorderless()Ripple()canUseNativeForeground() |
RESETRUNFULL
import React, { useState } from "react";import { Text, View, StyleSheet, TouchableNativeFeedback, StatusBar }
from "react-native";const App = () => {
const [rippleColor, setRippleColor] = useState(randomHexColor());
const [rippleOverflow, setRippleOverflow] = useState(false);
return (
<View style={styles.container}>
<TouchableNativeFeedback
onPress={() => {
setRippleColor(randomHexColor());
setRippleOverflow(!rippleOverflow);
}}
background=
{TouchableNativeFeedback.Ripple(rippleColor, rippleOverflow)}>
<View style={styles.touchable}>
<Text style={styles.text}>TouchableNativeFeedback</Text>
</View>
</TouchableNativeFeedback>
</View>
);};const randomHexColor = () => {
return "#000000".replace(/0/g, function() {
return (~~(Math.random() * 16)).toString(16);
});};const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
paddingTop: StatusBar.currentHeight,
backgroundColor: "#ecf0f1",
padding: 8},
touchable: { flex: 0.5, borderColor: "black", borderWidth: 1 },
text: { alignSelf: "center" }});export default App;