【发布时间】:2019-03-13 10:27:26
【问题描述】:
我正在编写我的第一个 React-native 应用程序,我在执行代码时收到以下错误消息,
App.js:
import React, { Component } from 'react';
import { StyleSheet, Text, TextInput, View} from 'react-native';
import { StackNavigator } from 'react-navigation';
import Login from './App/components/Login.js';
const Application = StackNavigator({
Home: { screen: Login },
}, {
navigationOptions: {
header: false,
}
});
export default class App extends Component {
render() {
return (
<Application />
);
}
}
登录.js:
import React,{Component} from 'react';
import{
View,
Text,
Stylesheet
} from 'react-native';
import { StackNavigator } from 'react-navigation';
export default class Login extends Component{
render(){
return(
<Text>Test</Text>
);
}
}
【问题讨论】:
-
您使用的是哪个版本的
react-navigation? -
@Andrew 如何检查?因为我只是运行命令
npn install --save react-navigation。我在 1 小时前安装了它。表示它是最新的。 -
那么您的问题是您正在学习旧教程,因为
StackNavigator在 v2 中已被弃用。由于您可能使用的是 v3,因此您需要确保使用正确的功能等,请查看文档以获取更多详细信息。 -
@Andrew 感谢您指出我使用的是旧教程。从现在开始我将使用最新的。谢谢。
标签: javascript android react-native react-navigation