question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't get anything to render with 3.1.0

See original GitHub issue

Hi there,

First off, thank you for building this component, it’s been very useful thus far!

I upgraded to the flat-list branch before you released 3.0.0 and it was working fine, but now that I’m using 3.1.0 I can’t get anything to render. I had it working just fine with the prerelease branch, so I’m not sure what changed.

Here’s an example that just shows a white screen on both iOS and Android:

import React, { PureComponent } from 'react';
import {
    Dimensions,
    StyleSheet,
    View,
} from 'react-native';

import Carousel from 'react-native-snap-carousel';

export default class ExampleCarousel extends PureComponent {
    state = {
        data: [{}, {}, {}, {}, {}, {}],
    }

    renderItem = () => (
        <View style={styles.tile} />
    );

    render() {
        return (
            <View style={styles.container}>
                <Carousel
                    data={this.state.data}
                    renderItem={this.renderItem}
                    itemWidth={Dimensions.get('window').width * 0.85}
                    sliderWidth={Dimensions.get('window').width}
                    style={styles.carousel}
                />
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
    },
    carousel: {
        flex: 1,
        backgroundColor: 'red',
    },
    tile: {
        flexGrow: 1,
        backgroundColor: 'red',
    },
});

Can you let me know how to debug this further? I think I’m following the readme, and I did verify that the Container view is filling the entire screen by changing its background color to green, which made the screen green. So I know the carousel has enough space, it just doesn’t seem to render anything.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

6reactions
bd-arccommented, Sep 5, 2017

Hey @blargity,

I had time to try your example and found out what was missing:

  • you were using style instead of containerCustomStyle (I will push a commit to make it interchangeable)
  • you forgot to transfer { flex: 1 } with slideStyle
  • your tile element was missing a width.

Here is the updated code:

import React, { PureComponent } from 'react';
import { Dimensions, StyleSheet, View } from 'react-native';

import Carousel from 'react-native-snap-carousel';

export default class ExampleCarousel extends PureComponent {
    state = {
        data: [{}, {}, {}, {}, {}, {}]
    }

    renderItem = () => (
        <View style={styles.tile} />
    );

    render () {
        return (
            <View style={styles.container}>
                <Carousel
                  data={this.state.data}
                  renderItem={this.renderItem}
                  itemWidth={Dimensions.get('window').width * 0.85}
                  sliderWidth={Dimensions.get('window').width}
                  containerCustomStyle={styles.carousel}
                  slideStyle={{ flex: 1 }}
                />
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        height: 300
    },
    carousel: {
        flex: 1,
        backgroundColor: 'red'
    },
    tile: {
        flex: 1,
        width: Dimensions.get('window').width * 0.85,
        backgroundColor: 'yellow'
    }
});
1reaction
adarshTScommented, Sep 7, 2017

@bd-arc It finally worked after doing this :

  • I uninstalled and reinstalled react-native-snap-carousel by doing this I could get the item name and index details in a console but still had some errors when I gave source={item} so then,

  • I replaced source={item} to source={item.item} and now the images are displayed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't get anything to render with 3.1.0 · Issue #134 - GitHub
I upgraded to the flat-list branch before you released 3.0.0 and it was working fine, but now that I'm using 3.1.0 I can't...
Read more >
T96485 Issue with rendering Blender 3.1.0
Main Issue: My animation is 1-120 frames. The issue is that past 115~117 frames I get black/weird textures showing up in the Render...
Read more >
FAQ | Unity Render Streaming | 3.1.0-exp.4
FAQ. Errors. Video stream not showing in browser. The browser version might be too old. Make sure that the latest version is installed....
Read more >
Tutorial | Unity Render Streaming | 3.1.0-exp.3
Check Package Manager window, Click Advanced button and enable Show preview packages . Select show preview packages on advanced options. Input ...
Read more >
Blender: A Cycles render settings guide - Artisticrender.com
Let's get back to the culling section. It doesn't have anything to do with animals. Instead these settings will help us automatically remove...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found