Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with "createDrawerNavigator" #11973

Open
2 of 11 tasks
stefunlive0 opened this issue May 3, 2024 · 5 comments
Open
2 of 11 tasks

Problem with "createDrawerNavigator" #11973

stefunlive0 opened this issue May 3, 2024 · 5 comments

Comments

@stefunlive0
Copy link

stefunlive0 commented May 3, 2024

Current behavior

I would like to launch an app on Expo (Android Studio Giraffe) but I have this error

Android Bundling failed 20738ms (C:\Users\My-User\Desktop\Projet01\node_modules\expo\AppEntry.js)
Unable to resolve "@react-navigation/drawer" from "App.jsx"    
Android Bundling failed 31085ms (C:\Users\My-User\Desktop\Projet01\node_modules\expo\AppEntry.js)
Unable to resolve "@react-navigation/drawer" from "App.jsx"

Please can you solve the bug in my code ? :

import * as React from 'react';
import { Button, View, Text } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createDrawerNavigator } from '@react-navigation/drawer';

function HomeScreen(props) {
  return (
    <View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
      <Text>Bonjour</Text>
      <Button title='Contact' onPress={() => {props.navigation.navigate('Contact')}}/>
    </View>
  )
};

function ContactScreen(props) {
  return (
    <View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
      <Text>Contact</Text>
      <Button title='Contact' onPress={() => {props.navigation.navigate('Home')}}/>
    </View>
  )
};

/*
const Stack = createStackNavigator();
const Tabs = createBottomTabNavigator();
*/
const Drawer = createDrawerNavigator();

export default function App() {
  return (
    <NavigationContainer>
      <Drawer.Navigator
        screenOptions={{
          headerStyle: {
            backgroundColor: 'green'
          },
          headerTitleStyle:{
            color: 'white',
            fontWeight: 'bold'
          }
        }}

      >
        <Drawer.Screen name='Home' component={HomeScreen}/>
        <Drawer.Screen name='Contact' component={ContactScreen}/>
      </Drawer.Navigator>
    </NavigationContainer>
  )
};

Thanks in advance

Expected behavior

Normally it works every time when I test new React component.
I don't undestand where is the problem

Reproduction

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAKjgQwM5wEoFNkGN4BmUEIcA5FDvmQNwBQokscA3nAEICuMMEAdgBo4ANWBYA7kIAqWAB7wAvnCIlylPDAC0fZDGAA3LLQbho8NgDlk+4AHNdwfgGF+MZMD5YocJStJkAAXV8bWs7B34Aeh09Q2NGM1Y4XHUYLABlN1wAaysbe15vX2J-IKotHXyIvkjULOz402Y2FJw09ggeEilkACM88MKfZRLyMo1Qqr0o3s7eEE03XtRGpnNk1KwAEShkcS8BguhhvzHgirCCxxqAE139qGM6Ak4+fGu4AAkSDNasPgAFGBiGBUABKVh0OBwSgwThQPhwAFQ6FwAA8ogkcDqAE8ADZYAC8LBYBAJsgAXHAAIxCZB4ux8ACSaRAqCpZFw-zSjyEACtOHVgAQcS4+GlxRyueKvGQFAoAHwo1HomTyBUdPh8iDwtGRNUwJUq6ForhdRF6GAEwlkMVZGBkOD8AAKlFQqGJAIhhIVrGBEFBADpKoNrsHLrosADba4NGQwfLIkbUXrMeJk2C6Ap6M9Xu9+HA7Rp0n9Af7QRCWCjYfDEciVRixOJsTB8USSWS5FTaSgGbZmaz2eRpTyyPzBXoRXbuVLubL5cmGwaFUX8Hrl8qU2beBbgFaiTHxXGnXxXVh3Z7vb6WOXUOGpmGQwUo2RviAjAmFEnN6mmxmszmkQIHQuD8HUcCZHg2RwISGxtBk9SHLo0BevQoF8OBPTLDBcGRh0XQgFhSGFKhdAIJEIFgfAOx7F4OGtJGNEPMRKFgjmchrHANxYAQyCcHihB5tMiIAIJgGAXqQtCNYIkiP7EdcRYeF4i4pkxXiBixUCbiqqClgA8mAwkeiSOnGgAFjg3FQJkbZUlWxqOXAvRQbYxCvDcLh4tAHJuVg-xkGZKoKAIQWopZyDWVIe4ErZBIUg5TkqqB3lQBy4jmXuRihUlKoEK4ADqWB2OZMAcrMeI3IFuU+GF8p0GZqkNupUCBiWlD-HAOjvjab5GMkJCQJ44rEn17X+XwX5NWp9waeNnXdQeq4OgNpjDTAxLLfNk3fo5eotZpEaFKpeoKc4sbKVA-7ZkAA

Platform

  • Android
  • iOS
  • Web
  • Windows
  • MacOS

Packages

  • @react-navigation/bottom-tabs
  • @react-navigation/drawer
  • @react-navigation/material-top-tabs
  • @react-navigation/stack
  • @react-navigation/native-stack
  • react-native-tab-view

Environment

  • [] I've removed the packages that I don't use
package version
@react-navigation/native 6.1.17
@react-navigation/drawer 6.6.15
@react-navigation/material-top-tabs 6.6.13
@react-navigation/native-stack
react-native-safe-area-context
react-native-screens
react-native-gesture-handler
react-native-reanimated
react-native-tab-view 3.5.2
react-native-pager-view
react-native
expo
node
npm or yarn
Copy link

github-actions bot commented May 3, 2024

Hey @stefunlive0! Thanks for opening the issue. It seems that the issue doesn't contain a link to a repro.

The best way to get attention to your issue is to provide an easy way for a developer to reproduce the issue.

You can provide a repro using any of the following:

A snack link is preferred since it's the easiest way to both create and share a repro. If it's not possible to create a repro using a snack, link to a GitHub repo under your username is a good alternative. Don't link to a branch or specific file etc. as it won't be detected.

Try to keep the repro as small as possible by narrowing down the minimal amount of code needed to reproduce the issue. Don't link to your entire project or a project containing code unrelated to the issue. See "How to create a Minimal, Reproducible Example" for more information.

You can edit your original issue to include a link to the repro, or leave it as a comment. The issue will be closed automatically after a while if you don't provide a repro.

Copy link

github-actions bot commented May 3, 2024

Couldn't find version numbers for the following packages in the issue:

  • @react-navigation/native
  • @react-navigation/drawer
  • @react-navigation/material-top-tabs
  • react-native-tab-view

Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.

@stefunlive0
Copy link
Author

It's updated

@Vikas-singh-0
Copy link

@stefunlive0 I ran npm install instead of npx expo install and one extra step from documentation,
npx expo install react-native-gesture-handler react-native-reanimated

Please try this if it helps.

`// import 'react-native-gesture-handler'
import { createDrawerNavigator } from "@react-navigation/drawer";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { Button, StyleSheet, Text, View } from "react-native";

function HomeScreen() {
return (
<View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
Home Screen

);
}

function NotificationsScreen({ navigation }) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Button onPress={() => navigation.goBack()} title="Go back home" />

);
}

const Drawer = createDrawerNavigator();

export default function App() {
return (

<Drawer.Navigator initialRouteName="Home">
<Drawer.Screen name="Home" component={HomeScreen} />
<Drawer.Screen name="Notifications" component={NotificationsScreen} />
</Drawer.Navigator>

);
}

const Stack = createNativeStackNavigator();

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
text: {
display: "flex",
backgroundColor: "red",
height: "1000px",
color: "black",
},
btn: {
width: "100px",
height: "100px",
backgroundColor: "red",
},
});
`
I am using expo to run the app.

@stefunlive0
Copy link
Author

stefunlive0 commented May 11, 2024

@stefunlive0 I ran npm install instead of npx expo install and one extra step from documentation, npx expo install react-native-gesture-handler react-native-reanimated

Please try this if it helps.

`// import 'react-native-gesture-handler' import { createDrawerNavigator } from "@react-navigation/drawer"; import { NavigationContainer } from "@react-navigation/native"; import { createNativeStackNavigator } from "@react-navigation/native-stack"; import { Button, StyleSheet, Text, View } from "react-native";

function HomeScreen() { return ( <View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}> Home Screen ); }

function NotificationsScreen({ navigation }) { return ( <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> <Button onPress={() => navigation.goBack()} title="Go back home" /> ); }

const Drawer = createDrawerNavigator();

export default function App() { return ( <Drawer.Navigator initialRouteName="Home"> <Drawer.Screen name="Home" component={HomeScreen} /> <Drawer.Screen name="Notifications" component={NotificationsScreen} /> </Drawer.Navigator> ); }

const Stack = createNativeStackNavigator();

const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: "#fff", alignItems: "center", justifyContent: "center", }, text: { display: "flex", backgroundColor: "red", height: "1000px", color: "black", }, btn: { width: "100px", height: "100px", backgroundColor: "red", }, }); ` I am using expo to run the app.

Hello I have this error :
Android Bundling failed 29987ms (C:\Users\My-User\Desktop\Projet01\node_modules\expo\AppEntry.js)
Unable to resolve "@react-navigation/drawer" from "App.jsx"

I think that

import { createDrawerNavigator } from "@react-navigation/drawer";

creates the error.

I need to add this :

import 'react-native-gesture-handler'

?

I used also this :

npx expo install react-native-gesture-handler react-native-reanimated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants