我在视图中使用NativeBase的DeckSwiper(docs,code),每次都出现错误:
Warning: React.createElement: type should not be null, undefined,
boolean, or number. It should be a string (for DOM elements) or a
ReactClass (for composite components). Check the render method of `CardSwiper`.
此标记有效:
<View flex>
<DeckSwiper dataSource={cards} renderItem={(item) => {
console.log(item);
return (
<Text flex>{item.text}</Text>
)
}}/>
但是在Text
的此标记中(从他们的站点)取消失败,出现上述错误:
<Card style={{
elevation: 3
}}>
<CardItem>
<Thumbnail source={item.image}/>
<Text>{item.text}</Text>
<Text note>NativeBase</Text>
</CardItem>
<CardItem>
<Image style={{
resizeMode: 'cover',
width: null
}} source={item.image}/>
</CardItem>
<CardItem>
<Icon name="ios-heart" style={{
color: '#ED4A6A'
}}/>
<Text>{item.name}</Text>
</CardItem>
</Card>
我不知道我使用的是错误的还是文档已关闭或这是一个错误。这里有什么问题?
您必须从“ react-native”而不是从“ native-base”导入“ Image”
示例代码:
import { Image } from 'react-native';
import { Container, Header, View, DeckSwiper, Card, CardItem, Thumbnail, Text, Left, Body, Icon } from 'native-base';