Closed
Description
New to Development, trying to learn React Native but having an issue when trying to install Hooks. Using Expo Go, which is also showing an issue, says Index.js doesn't exist for hooks. I've already installed Hooks using NPM.
This is my code:
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View, Image, SafeAreaView, Button, Alert, Dimensions } from 'react-native';
import { useDeviceOrientation } from '@react-native-community/hooks'
export default function App() {
const orientation = useDeviceOrientation()
console.log('is orientation portrait: ', orientation.portrait)
console.log('is orientation landscape: ', orientation.landscape)
const handleButtonPress = () => {
Alert.prompt("Title", "This is my message", text => console.log(text))
}
return (
<SafeAreaView style={styles.container}>
<Button
onPress={handleButtonPress}
title={"Press me!"}
/>
<Text>Hello!</Text>
<StatusBar style="auto" />
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f1f1f1',
alignItems: "center",
justifyContent: "center",
},
});
Metadata
Metadata
Assignees
Labels
No labels