找不到不变违规视图配置

时间:2018-01-20 16:07:01

标签: reactjs react-native reactive-programming

当我运行代码时,我收到此错误:

找不到

不变违规视图配置

index.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>
    );
  };
}

main.js代码是:

Set

请帮助

1 个答案:

答案 0 :(得分:0)

组件名称必须大写为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>
    );
  };
}