2

我在视图中使用 NativeBase 的 DeckSwiper (docscode),每次都会出错:

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>

我不知道是我用错了还是文档关闭了,或者这是一个错误。这里有什么问题?

4

1 回答 1

1

您必须从“react-native”导入“Image”,而不是从“native-base”导入

示例代码:

import { Image } from 'react-native';
import { Container, Header, View, DeckSwiper, Card, CardItem, Thumbnail, Text, Left, Body, Icon } from 'native-base';
于 2019-11-19T07:52:10.053 回答