如何在NativeBase中使用DeckSwiper元素而不出现“元素类型无效”错误?

问题描述 投票:2回答:1

我在视图中使用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>

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

javascript android ios react-native native-base
1个回答
0
投票

您必须从“ 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';
© www.soinside.com 2019 - 2024. All rights reserved.