React Native error in React-navigation-stack on Android

Asked

Viewed 662 times

-1

Hello, I’ve tried to solve this problem with various solutions and nothing, always give me the same mistake.

I did all the procedures you tell me on his website for me to do, createStackNavigator, and yet the error is appearing.

inserir a descrição da imagem aqui

Down here are the dependencies I’m using.

inserir a descrição da imagem aqui

One of the solutions I’ve tried to give downgrade dependencies, but in my case did not help.

I’ve also put the necessary codes in the android folder. This problem only comes when I put the react-navigation-stack in my js file.

import { createAppContainer, createSwitchNavigator } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';

import White from './pages/White';
import Login from './pages/Login';
import Main from './pages/Main';

const AppScreen = createStackNavigator({ Main });
const NoAuthScreen = createStackNavigator({ Login });

export default createAppContainer(
    createSwitchNavigator(
        {
            White,
            AppScreen,
            NoAuthScreen
        },
        {
            initialRouteName: 'White',
        }
    )
);

If I take the react-navigation-stack import of my file the problem disappears and the app works properly, but I really need the react-navigation-stack to make my app, because I want to do the auth part on the routes and I’m following what it tells me on this website for me to make.

Who can help I love very much, because I’m still at the beginning of the project and is already making mistakes that I can not understand why. Thank you.

  • What have you added to the android folder? Undo that it will work. In React Native 0.60 or higher it is no longer necessary to use the link for many packages. This React Native navigation package plus the helpers link is done automatically. Don’t forget to add in the package.json scripts section that "postinstall": "npx jetify"

  • What I added to the android folder is what is requested when installing the react-native-gesture-handler Getting Started.

  • I managed to solve my problem! After having read the Docs of the React Navigation I noticed that in version 3 it already brings the createStackNavigator in his import, and since it did not cause the error, I can consider that my problem is solved. Of course it would be good to be able to use the most updated version but as it is working well I will leave it so. Then I should update the post only with the procedures I did. Thank you.

  • 1

    And is coming new update of React Navigation ai on. Version 5 is in beta :)

1 answer

0

By the description of the error, it was not possible to link the library "React-Native-Gesture-Handler" with your project. This library is already part of your "package-json".

Do the following:

react-native link react-native-gesture-handler

And then install again:

react-native run-android
  • 1

    In the version of React Nactivate that it is using it is not necessary to use the link!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.