“Bereaksi Native Touchableopacity” Kode Jawaban

Bereaksi Native Touchableopacity Nonaktifkan

<TouchableOpacity disabled={true}>
  <Text>I'm disabled</Text>
</TouchableOpacity>
Friendly Finch

Bereaksi Native Touchableopacity

import React, { useState } from "react";
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";

const App = () => {
  const [count, setCount] = useState(0);
  const onPress = () => setCount(prevCount => prevCount + 1);

  return (
    <View style={styles.container}>
      <View style={styles.countContainer}>
        <Text>Count: {count}</Text>
      </View>
      <TouchableOpacity
        style={styles.button}
        onPress={onPress}
      >
        <Text>Press Here</Text>
      </TouchableOpacity>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: "center",
    paddingHorizontal: 10
  },
  button: {
    alignItems: "center",
    backgroundColor: "#DDDDDD",
    padding: 10
  },
  countContainer: {
    alignItems: "center",
    padding: 10
  }
});

export default App;
MAKSTYLE119

Touchableopacity

 <TouchableOpacity
        style={styles.button}
        onPress={onPress}
      >
        <Text>Press Here</Text>
      </TouchableOpacity>
Arvind Jitta

Jawaban yang mirip dengan “Bereaksi Native Touchableopacity”

Pertanyaan yang mirip dengan “Bereaksi Native Touchableopacity”

Lebih banyak jawaban terkait untuk “Bereaksi Native Touchableopacity” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya