Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeskSwiper throws on single element lists #562

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

DeskSwiper throws on single element lists #562

StephenGrider opened this issue Feb 23, 2017 · 5 comments

Comments

@StephenGrider
Copy link

@StephenGrider StephenGrider commented Feb 23, 2017

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
Copy link
Collaborator

@sankhadeeproy007 sankhadeeproy007 commented Feb 24, 2017

Thanks for reporting. Will look into it!

@sankhadeeproy007
Copy link
Collaborator

@sankhadeeproy007 sankhadeeproy007 commented Mar 3, 2017

Fixed with v2.0.12

@hindsricardo
Copy link

@hindsricardo hindsricardo commented Mar 24, 2017

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

@anmolmayank
Copy link

@anmolmayank anmolmayank commented Oct 4, 2017

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

@glynnallen1704
Copy link

@glynnallen1704 glynnallen1704 commented Mar 13, 2018

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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.