this below code isn’t work, please tell me whats wrong with this code?
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, Text, View,Button } from 'react-native';
export default function App() {
handle()
{
console.log("pressed");
}
return (
<View style={styles.container}>
<Text>HEllo World!</Text>
<Button variant="outlined" title = " hello" onPress={handle}></Button>
<StatusBar style="auto" />
</View>
);
}
const st
yles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
I’m just try to print some text in console, when the button is pressed.
2
Answers
just change it to:
and then:
here is the working code!
you can’t use function like this way
it’s not working so can use like this way
App.js