我正在关注教程,我正面临着这个错误。
不变违规:元素类型无效,预期字符串但得到 宾语: 检查'Home'的渲染方法 此错误位于:
在家中(在index.js:12)
这是我的文件结构:
index.js:
import React from 'react';
import EStyleSheet from 'react-native-extended-stylesheet';
import Home from './screens/Home';
EStyleSheet.build({
$primaryBlue:'#4F6D7A',
$white:'#fff'
});
export default ()=> <Home/>;
home.js:
import React,{Component} from 'react';
import {View,StatusBar} from 'react-native';
import Container from '../components/Container';
import Logo from '../components/Logo';
import InputWithButton from '../components/TextInput';
class Home extends Component {
render(){
return (
<Container>
<StatusBar translucent={false} barStyle="light-content">
</StatusBar>
<Logo/>
<InputWithButton/>
<InputWithButton/>
</Container>
);
}
}
export default Home;
Container.js:
import React from 'react';
import PropTypes from 'prop-types';
import {View} from 'react-native';
import styles from './styles';
const Container = ({children})=>(
<View style = {styles.Container}>
{children}
</View>
);
Container.propTypes={
children:PropTypes.any,
};
export default Container;