DeskSwiper throws on single element lists
React Native v0.41 React 15.4.0 NativeBase v2.0
Expected Behavior
DeckSwiper shows a single card when the dataSource prop is an array of length one.
Actual Behavior
DeckSwiper throws an error when the dataSource prop is an array of length one.
Steps to reproduce
- Create a new ReactNative App, install NativeBase, link it.
- Paste the official DeckSwiper snippet with only one element in the
cardsarray.
import React, { Component } from 'react';
import { Image, View } from 'react-native';
import { Container, Icon, DeckSwiper, Card, CardItem, Left, Body, Thumbnail, Text } from 'native-base';
const cards = [
{
text: 'Card One',
name: 'One'
}
];
export default class DeckSwiperExample extends Component {
render() {
return (
<Container>
<View>
<DeckSwiper
dataSource={cards}
renderItem={item =>
<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>
}>
</DeckSwiper>
</View>
</Container>
);
}
}
- Run! Result is an error
Cannot read property 'image' of undefined. - Add another card
- Run! Deckswiper shows up as expected.
Is the bug present in both ios and android or in any one of them? Confirmed only on iOS.
Thanks for reporting. Will look into it!
Fixed with v2.0.12
I am on version 2.0.13 and still experiencing the issue with a single element array.
I am on Version 2.3.1 , experiencing the issue with a single element array .
2.3.10 and also having an issue with an array of 8 elements