简体   繁体   中英

Error while importing react-navigation & native-base

I am new to react when I import stacknavigator from react-navigation or listitem from native-base .

  1. Created new project on expo.
  2. npm install --save react-navigation .
  3. npm install .
  4. npm start enter code here

I continuously get this error, tried the solution from GitHub repo issue number 4968 but that's not helpful, can you help, please? unable to resolve react-navigation, module doesn't exist in module map

 App.js {import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; import {StackNavigator} from 'react-navigation' import LoginScreen from './Screens/LoginScreen' import HomeScreen from './Screens/HomeScreen' export default class App extends React.Component { render() { return ( <AppNavigator/> ); } } const AppNavigator = StackNavigator({ LoginScreen : {screen : LoginScreen}, HomeScreen : {screen : HomeScreen} }) const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#fff', alignItems: 'center', justifyContent: 'center', }, });` LoginScreen.js ` import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; export default class LoginScreen extends React.Component { render() { return ( <View> <Text> This is login Screen </Text> </View> ); } } export default LoginScreen;` 

Using react-native, after you install a new package with npm install , you must run react-native link to update your node-modules folder. Then, if using android and if it is needed, you can run:

cd android && gradlew clean
cd .. & react-native run-android

Also, your code presents some syntax errors in imports. Fix ; in end lines and the { at line 3 .

Check NativeBase Docs. Installation for RN, Expo and web app are documented clearly.

Also check https://reactnativeseed.com/ for working examples

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM