I am a newcomer to React Native and TypeScript, and I am struggling to figure out how to display something on the page of my app after a button is pressed.
Below is the function I'm using:
const getRandomNumber = () ={
const number = Math.floor(Math.random()*5000 + 1)
alert(number)
return <Text>{number}</Text>
}
Here is where I am calling the function:
return(
<View style={{flex: 1, justifyContent: "center", margin: 8}}>
<Text>Random number</Text>
<Button
title="Press me"
onPress={() => getRandomNumber()}
color="#32a852"
/>
</View>
)