本文介绍了响应本机不变:查看配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在React Native项目上使用不同的屏幕进行练习.这是我的App.js文件中的代码.
I'm trying to practice with different screens on a React Native project. Here's my code from App.js file.
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View
} from 'react-native';
import { StackNavigator } from 'react-navigation';
class HomeScreen extends React.Component {
static navigationOptions = {
title: "welcome",
};
render() {
return <Text style={{ color: 'black '}}>Hello, Navigation!</Text>;
}
}
const navigation = StackNavigator({
Home: { screen: HomeScreen },
});
export default class App extends Component<{}> {
render() {
return <navigation/>;
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#fff',
},
});
当我运行react-native run-android时,我看到一个Invariant Violation,它告诉我查看未找到的配置或名称导航".然后所有发生此违规行为的站点.帮助,请谢谢.
When I run react-native run-android I get an Invariant Violation which tells me "to view config not found or name navigation". And then all the sites where this violation happens.Help please thanks.
推荐答案
任何组件的名称都必须大写.用您的名字,导航"组件不大写.应该是导航".
The name of any component must be capitalized. In your name, the component "navigation" is not capitalized. It should be "Navigation".
这篇关于响应本机不变:查看配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!