Skip to content

Unable to resolve "@react-native-community/hooks" from "App.js" #308

Closed
@rajangra

Description

@rajangra

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions