首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法从"App.js“解析"react-navigation-stack”

无法从"App.js“解析"react-navigation-stack”
EN

Stack Overflow用户
提问于 2020-06-17 01:17:08
回答 1查看 274关注 0票数 0

代码语言:javascript
复制
***package.json***
{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@react-native-community/masked-view": "^0.1.10",
    "@react-navigation/native": "^5.5.1",
    "expo": "~37.0.3",
    "react": "~16.9.0",
    "react-dom": "~16.9.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",
    "react-native-gesture-handler": "^1.3.0",
    "react-native-paper": "^3.10.1",
    "react-native-safe-area-context": "^3.0.5",
    "react-native-web": "~0.11.7",
    "react-navigation": "^4.3.9",
    "react-navigation-material-bottom-tabs": "^2.2.12",
    "react-navigation-stack": "^2.7.0"
  },
  "devDependencies": {
    "babel-preset-expo": "~8.1.0",
    "@babel/core": "^7.8.6"
  },
  "private": true
}

您好,我正面临一个反应导航的问题

我安装了react导航依赖项,但仍然出错

代码语言:javascript
复制
***App.js***
import React from 'react'
import{StyleSheet,Text,View}from 'react-native'
import { createStackNavigator } from "react-navigation-stack";
import { createAppContainer } from "react-navigation";

import SignUp from './App/SignUp'
import SignIn from './App/SignIn'
import ForgotPassword from './App/ForgotPassword'

 class App extends React.Component{
  render(){
    return(
      <View style={styles.container}>
      </View>
    )
  }
}
const navigator=createStackNavigator(
  {
    Registration:SignUp,
    Login:SignIn,
    Password:ForgotPassword
  },
  {
initialRouteName:'SignUp',
defaultNavigationOptions:{
  title:'App'
}
  }
)
const styles=StyleSheet.create({
  container:{
    flex:1,
    justifyContent:'center',
    backgroundColor:'#fff',
    paddingLeft:60,
    paddingRight:60,
  },
})
export default createAppContainer(navigator)

代码语言:javascript
复制
***SignUp***
import React from 'react'
import{StyleSheet,Text,View,TextInput,TouchableOpacity, ImagePropTypes}from 'react-native'

export default class SignUp extends React.Component{
  render(){
    return(
      <View style={styles.signup}>
         <Text style={styles.Text}/>
         <Text style={styles.string}>Hi There!</Text>
         <Text style={styles.string}>Welcome To APPTAK</Text>
    <Text style={styles.Text}>FULL NAME</Text>
    <TextInput style={styles.textinput} placeholder="Please Enter Your Name" underlineColorAndroid={'transparent'} />
    <Text style={styles.Text}>EMAIL</Text>
    <TextInput style={styles.textinput} placeholder="Please Enter Your Email" underlineColorAndroid={'transparent'} keyboardType='email-address' />
    <Text style={styles.Text}>PASSWORD</Text>
    <TextInput style={styles.textinput} placeholder="Please Enter Your Password" secureTextEntry={true} underlineColorAndroid={'transparent'} />
    <Text style={styles.Text}>MOBILE NUMBER</Text>
    <TextInput style={styles.textinput} placeholder="Please Enter Your Mobile Number"  underlineColorAndroid={'transparent'} keyboardType='numeric'/>
    <Text style={styles.Text}>CNIC</Text>
    <TextInput style={styles.textinput} placeholder="Please Enter Your CNIC"  underlineColorAndroid={'transparent'}          keyboardType='numeric'/>
     <TouchableOpacity style={styles.button}>
         <Text style={styles.btntext}>Sign Up</Text>
     </TouchableOpacity>

      </View>
      
    )

  }
}
const styles=StyleSheet.create({
  signup:{
    alignSelf:'stretch',
  },
  header:{
      fontSize:24,
      color:'#6069f2',
      paddingBottom:10,
      marginBottom:40,
      borderBottomColor:'#199187',
      borderBottomWidth:1,
  },
  textinput:{
      alignSelf:'stretch',
      height:40 ,
      marginBottom:30,
      color:'#1D1105',
      borderBottomColor:'#f8f8f8',
      borderBottomWidth:1,
  },
  button:{
      alignSelf:'stretch',
      alignItems:'center',
      padding:20,
      backgroundColor:'#6069f2',
      marginTop:30,  
  },
  btntext:{
   color:'#fff',
   fontWeight:'bold'
  },
  string:{
    alignContent:'center',
    justifyContent:'center',
    textAlign: 'center',

  }
})

我尝试了堆栈溢出上已经存在的所有解决方案,至少对我来说没有一个有效

EN

回答 1

Stack Overflow用户

发布于 2020-06-17 01:21:39

React导航现在从不同路径导入

代码语言:javascript
复制
import {NavigationContainer} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack';

同时安装这些包

代码语言:javascript
复制
npm install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view

Documentation https://reactnavigation.org/docs/getting-started

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62414088

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档