I am new to React Native. Recently I try to figure out stack navigator. I runned these comments on terminal.
npm install @react-navigation/native npm install react-native-screens react-native-safe-area-context npm install @react-navigation/stack npm install react-native-gesture-handler
here is my code:
import React from "react";
import { StyleSheet, View, Text, AppState } from "react-native";
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
const Stack = createStackNavigator();
function ScreenA(){
return(
<View>
<Text> Screen A</Text>
</View>
)
}
function App(){
return(
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name="Screen_A"
component={ScreenA}
/>
</Stack.Navigator>
</NavigationContainer>
)
}
export default App;
And I get this error message: error
While trying to resolve module @react-navigation/elements
from file /Users/ogulcanozen/food/node_modules/@react-navigation/stack/src/views/Header/Header.tsx
, the package /Users/ogulcanozen/food/node_modules/@react-navigation/elements/package.json
was successfully found. However, this package itself specifies a main
module field that could not be resolved (/Users/ogulcanozen/food/node_modules/@react-navigation/elements/src/index.tsx
. Indeed, none of these files exist: