【问题标题】:invariant violation view config not found未找到不变违规视图配置
【发布时间】:2018-06-29 16:54:03
【问题描述】:

当我运行代码时,我得到这个错误:

未找到不变违规视图配置

index.js 代码是:

import { AppRegistry, Text, Image, View } from 'react-native';
import React, { Component } from 'react';
import main from './src/codes/main';


class app extends Component{

  render(){
    return <main/>;
  }

}


AppRegistry.registerComponent('app', () => app);

main.js 代码是:

import React, { Component } from 'react';
import { Text, View } from 'react-native';


export default class main extends Component{
  render(){
    return (
      <View>
        <Text>Salam</Text>
      </View>
    );
  };
}

请帮忙

【问题讨论】:

标签: reactjs react-native reactive-programming


【解决方案1】:

组件名称必须大写作为 React Native 中的语法要求。

index.js

import { AppRegistry, Text, Image, View } from 'react-native';
import React, { Component } from 'react';
import Main from './src/codes/main';


class App extends Component{

  render(){
    return <Main/>;
  }

}


AppRegistry.registerComponent('App', () => App);

main.js

import React, { Component } from 'react';
import { Text, View } from 'react-native';


export default class Main extends Component{
  render(){
    return (
      <View>
        <Text>Salam</Text>
      </View>
    );
  };
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-08-04
    • 2023-03-29
    • 2020-05-06
    • 1970-01-01
    • 1970-01-01
    • 2020-04-29
    • 1970-01-01
    相关资源
    最近更新 更多