diff --git a/docs/touchablewithoutfeedback.md b/docs/touchablewithoutfeedback.md index 3bad6e24d02..f25908d3a0b 100644 --- a/docs/touchablewithoutfeedback.md +++ b/docs/touchablewithoutfeedback.md @@ -7,7 +7,7 @@ Do not use unless you have a very good reason. All elements that respond to pres `TouchableWithoutFeedback` supports only one child. If you wish to have several child components, wrap them in a View. Importantly, `TouchableWithoutFeedback` works by cloning its child and applying responder props to it. It is therefore required that any intermediary components pass through those props to the underlying React Native component. -### Usage Example +## Usage Pattern ```jsx function MyComponent(props) { @@ -23,6 +23,54 @@ function MyComponent(props) { ; ``` +## Example + +```SnackPlayer name=TouchableWithoutFeedback +import React, { useState } from "react"; +import { StyleSheet, TouchableWithoutFeedback, Text, View } from "react-native"; + +export default function TouchableWithoutFeedbackExample() { + const [count, setCount] = useState(0); + + const onPress = () => { + setCount(count + 1); + }; + + return ( + + + Count: {count} + + + + Touch Here + + + + ); +} + +const styles = StyleSheet.create({ + container: { + flex: 1, + justifyContent: "center", + paddingHorizontal: 10 + }, + button: { + alignItems: "center", + backgroundColor: "#DDDDDD", + padding: 10 + }, + countContainer: { + alignItems: "center", + padding: 10 + }, + countText: { + color: "#FF00FF" + } +}); +``` + --- # Reference