Unable to resolve "@react-native-community/hooks" from "App.js"
rajangra opened this issue · 2 comments
rajangra commented
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",
},
});
RohinMarok commented
I believe it could be due to the version of React that you have installed.
rajangra commented
I believe it could be due to the version of React that you have installed.
Thanks Rohan, i was able to update the version