-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Adding slides dynamically not rendered at first time #35
Comments
@lsps9150414 This is odd, considering I've tried appending dynamic slides just last week, and this was working as expected. Would you mind using the provided example as a starting point? You can add just a bit of logic and check if this works. Note that the example still uses RN version 0.38.0. We plan on updating it soon. |
@bd-arc I tried playing with the example but got the same result. All I did with the example is replacing renderSlides = () => {
console.log('[renderSlides]', this.state.slides);
return (
this.state.slides.map(slide => (
<View
style={{ backgroundColor: '#fff', width: itemWidth, height: 100 }}
key={`carousel-entry-${slide}`}
>
<Text>Slide {slide}</Text>
</View>
))
);
} addSlide = () => {
const newSlides = [...this.state.slides];
newSlides.push(newSlides.length);
this.setState({ slides: newSlides });
} Do you still have the code that you try appending dynamic slides? If |
@lsps9150414 I think your guess is spot on. I'm going to run a few tests as soon as I can before getting back to you. By the way, thank you for providing thorough details ;) |
@lsps9150414 I'm happy to let you know that this issue should be resolved with version 2.0.3 of the plugin. |
Hi! When I append a new slide, I lose the focus on the current slide and the first slide is focused.. that is not the expected behaviour since i'm implementing infinite pagination with snap-carousel |
I guess it has to do with this line. Still, it's pretty strange since this would mean that If you set |
Yes! |
Sorry for the delay; I've overlooked this issue since it was closed. Would you mind opening a new one with some code that can help me reproduce the matter? I should be able to take a look at it later this week... |
Did you get a solution to adding slides dynamically? Im unable to do it... Getting a
|
By logging out my slides (
medicationCards
) I am sure that new slide is added to the children ofCarousel
every time I clickADD
.However, it is not rendered for the first time.
Based on my loggings, the actual rendered slides fall 1 cycle before slides children updates, e.g. when
console.log('medicationCards = ', medicationCards);
prints 3 items, 2 are rendered; when it prints 4 items, 3 are rendered.The text was updated successfully, but these errors were encountered: