React Native Invariant Violation:查看配置 [英] React Native Invariant Violation: View config

查看:28
本文介绍了React Native Invariant Violation:查看配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 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".

这篇关于React Native Invariant Violation:查看配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆