Home > OS >  react navigation issue in react-native
react navigation issue in react-native

Time:10-21

I am a newbie at react-native and I am facing some issues in the react-native app, after installing 'react-navigation', everything is mentioned in the images. Hope you can help me. Have a good day.

App.js file

MainActivity.java

Package.json

Terminal-issue

Node-cli

CodePudding user response:

First: install @react-navigation/stack by npm install @react-navigation/stack using console(console must be opened in your project main directory).

Choose one:

  1. If you are using bare React-Native project install react-gesture-handler using npm install react-native-gesture-handler.

  2. If you are using expo managed project(e.g you created project using npx expo init) - use npx expo install react-native-gesture-handler.

Docs: https://reactnavigation.org/docs/stack-navigator/

After successfull install please restart your metro/expo server.

CodePudding user response:

Use createNativeStackNavigator from native-stack instead.

import * as React from 'react';
import { View, Text } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';

...

const Stack = createNativeStackNavigator();

function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator>
...
      </Stack.Navigator>
    </NavigationContainer>
  );
}

export default App;

See Installing the native stack navigator library for details.

  • Related