【发布时间】:2020-07-14 16:51:37
【问题描述】:
我是 React Native 的新手,这是我的主要 App.js 组件:
import React from 'react'
import { StyleSheet, Text, View } from 'react-native'
import { Ionincons} from '@expo/vector-icons'
export class App extends React.Component {
render (){
return (
<View style={styles.container}>
<Ionincons name='ios-pizza'/>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
}
})
当我尝试运行这个简单的代码时,我收到以下消息:
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s%s, undefined, You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
但是当我将 IonIcons 组件换成一个简单的
<Text>Hello</Text/> 一切正常。
我在这里错过了什么?
【问题讨论】:
标签: reactjs react-native react-native-android