Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6290

react native typescript get event target

$
0
0

i am new to react native with typescript and i have a problemi want to get the text from the Text component so it mean when i press the Text i will console log iti cant get the target valuei try also currentTargetbut it will give me a huge array of object with ton of keys without any target value

import { GestureResponderEvent, StyleSheet, Text, View } from "react-native";import React, { useState } from "react";import Card from "../../components/card/Card";import ChooseLotteryNumber from "../../components/choose_lottery_number/ChooseLotteryNumber";const CreateUser = () => {  const [selectedNumbers, setSelectedNumbers] = useState<number[]>([]);  const onSelectNumbers = (e: GestureResponderEvent )=>{    console.log(e.currentTarget)  };  return (<View><Card><View><Text onPress={onSelectNumbers}>choose numbers!</Text></View><View style={styles.number_container}></View></Card></View>  );};export default CreateUser;const styles = StyleSheet.create({  number_container: {    flexDirection: "row",    flexWrap: "wrap",    justifyContent: "center",    backgroundColor: "white",    borderRadius: 10,  },  number: {    fontSize: 24,    margin: 6,    borderWidth: 1,    borderRadius: 5,    textAlign: "center",    width: 35,  },});

Viewing all articles
Browse latest Browse all 6290

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>