Giter Site home page Giter Site logo

Comments (4)

bd-arc avatar bd-arc commented on May 18, 2024 1

@jonathandion I'll reproduce my answer to this issue :)

My guess is that you're trying to render the carousel while it has no child at all. Am I right? Indeed, this would fail since the component depends on children's length. We need to improve component's state management in order to handle this kind of usage.

For now, I would recommend you to render the carousel conditionally. Something along those lines:

get loader () {
    return (
        <ActivityIndicator size={'small'} />
    );
}

get carousel () {
    const { entries } = this.state;
    return (
        <Carousel>
            { entries }
        </Carousel>
    );
}

render () {
    const { products } = this.state;
    return !products.length ? this.loader : this.carousel;
}

Does this do the trick for you?

from react-native-snap-carousel.

bd-arc avatar bd-arc commented on May 18, 2024

@jonathandion Hi,
This is probably the same issue as #35. There must be something wrong with component's state management. I'll look into it as soon as possible.

from react-native-snap-carousel.

jonathandion avatar jonathandion commented on May 18, 2024

@bd-arc Hey Benoit,

Thanks sorry for the misunderstood. When I mean dynamic" I mean using data from my server using Ajax. When I use this.state.products I have that error.

this is working {this.renderProducts([{ title : "test"}, { title : "test" }])}
not {this.renderProducts(this.state.products)}

I fetch my products inside componentDidMount and set the state after receiving the data. The default state is this.state({ products: []}).

We really need to have data ?

from react-native-snap-carousel.

jonathandion avatar jonathandion commented on May 18, 2024

@bd-arc thanks it's working 👍

from react-native-snap-carousel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.