您好,我收到此错误“ Invarian Violation:元素类型无效:预期为字符串(对于内置组件)或类/函数(对于复合组件),但是得到了:object”,但我不知道为什么,我在这里做错的是我的代码和结构:
app.js
import React, { Component } from 'react';
import { View, Text } from 'react-native';
import { Header } from './components/common';
class App extends Component{
render() {
return(
<View>
<Header headerText = "Authentication" />
<Text>test</Text>
</View>
);
}
}
export default App;
index.js位于公共目录内
export * from './Button';
export * from './Card';
export * from './CardSection';
export * from './Header';
Header.js文件
import React from 'react';
import { Text, View } from 'react-native';
// Make a compoenent
const Header = (props) => {
const {textStyle, viewStyle} = styles;
return (
<View style={viewStyle}>
<Text style={textStyle}>{props.headerText}</Text>
</View>
);
};
const styles = {
viewStyle:{
backgroundColor: '#F8F8F8',
justifyContent:'center',
alignItems: 'center',
height: 60,
paddingTop: 0,
shadowColor: '#000',
shadowOffset: { width:0, height:2},
shadowOpacity: 0.9,
elevation: 2,
position: 'relative'
},
textStyle: {
fontSize: 20
}
};
// Make the component available for the other parts of the app
export { Header };