NativeBase icon indicating copy to clipboard operation
NativeBase copied to clipboard

DeskSwiper throws on single element lists

Open StephenGrider opened this issue 9 years ago • 5 comments

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

  1. Create a new ReactNative App, install NativeBase, link it.
  2. Paste the official DeckSwiper snippet with only one element in the cards array.
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>
        );
    }
}
  1. Run! Result is an error Cannot read property 'image' of undefined.
  2. Add another card
  3. 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.

StephenGrider avatar Feb 23 '17 18:02 StephenGrider

Thanks for reporting. Will look into it!

sankhadeeproy007 avatar Feb 24 '17 07:02 sankhadeeproy007

Fixed with v2.0.12

sankhadeeproy007 avatar Mar 03 '17 14:03 sankhadeeproy007

I am on version 2.0.13 and still experiencing the issue with a single element array.

hindsricardo avatar Mar 24 '17 03:03 hindsricardo

I am on Version 2.3.1 , experiencing the issue with a single element array .

anmolmayank avatar Oct 04 '17 07:10 anmolmayank

2.3.10 and also having an issue with an array of 8 elements

glynnallen1704 avatar Mar 13 '18 07:03 glynnallen1704