DeskSwiper throws on single element lists #562

Closed
StephenGrider opened this Issue Feb 23, 2017 · 5 comments

Comments

Projects
None yet
5 participants
@StephenGrider

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.

@sankhadeeproy007

This comment has been minimized.

Show comment
Hide comment
@sankhadeeproy007

sankhadeeproy007 Feb 24, 2017

Collaborator

Thanks for reporting. Will look into it!

Collaborator

sankhadeeproy007 commented Feb 24, 2017

Thanks for reporting. Will look into it!

@sankhadeeproy007

This comment has been minimized.

Show comment
Hide comment
@sankhadeeproy007

sankhadeeproy007 Mar 3, 2017

Collaborator

Fixed with v2.0.12

Collaborator

sankhadeeproy007 commented Mar 3, 2017

Fixed with v2.0.12

@hindsricardo

This comment has been minimized.

Show comment
Hide comment
@hindsricardo

hindsricardo Mar 24, 2017

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

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

@anmolmayank

This comment has been minimized.

Show comment
Hide comment
@anmolmayank

anmolmayank Oct 4, 2017

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

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

@glynnallen1704

This comment has been minimized.

Show comment
Hide comment
@glynnallen1704

glynnallen1704 Mar 13, 2018

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment