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

React native typescript render text onPress

$
0
0

So i am new to React native and typescript. I can't seem to find any way to print something on the page of my app, after a button is pressed.

Here is my function that is called:

 const getDuck = () =>{        const number = Math.floor(Math.random()*5000 + 1)        alert(number)        return <Text>{number}</Text>    }

And here is where i am calling it:

return(<View style={{flex: 1, justifyContent: "center", margin: 8}}><Text>Random number</Text><Button         title="Press me"         onPress={() => getDuck()}         color="#32a852"        /></View>    )

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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