Open VictorioMolina opened 1 year ago
My current solution:
const prevAlbumDataRef = useRef(data);
if (
recycled &&
prevAlbumDataRef.current?.[0].uri !== data[0].uri
) {
setActiveSlide(0);
carouselRef.current?.scrollTo({
index: 0,
animated: 0,
});
prevAlbumDataRef.current = data;
}
return <Carousel ref={carouselRef} ...
Could be nice to get it automatically done by the library.
Notice: react will not re-render if we update the state in the component's body, before the render. Look at getDerivedStateFromProps for more info.
Hi, Can you tell me how to reproduce this issue? I can't imagine this situation.
@dohooo Just use react-native-reanimated-carousel inside a FlashList. Check this resource: https://shopify.github.io/flash-list/docs/recycling
Other resource which might be helpful: https://github.com/Flipkart/recyclerlistview#why https://legacy.reactjs.org/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops
Describe the bug I am rendering a Carousel with dynamic length inside a FlashList componente.
When I scroll the 1st carousel to the 5th slide, and then scroll down my FlashList to the Nth component, as it is being recycled, the active slide in the first render is the same of the 1st carousel, but this component only has 3 slides.
How can we reset the active slide before render? Any
recycled
prop?Versions (please complete the following information):
Smartphone (please complete the following information):