meliorence / react-native-snap-carousel

Swiper/carousel component for React Native featuring previews, multiple layouts, parallax images, performant handling of huge numbers of items, and more. Compatible with Android & iOS.
BSD 3-Clause "New" or "Revised" License
10.37k stars 2.29k forks source link

<Pagination> Error : Rendered fewer hooks than expected. This may be caused by an accidental early return statement. #1023

Closed TanveerShah0 closed 5 months ago

TanveerShah0 commented 5 months ago

my code

const [activeSlide, setActiveSlide] = useState(0);

const renderPagination = () => { return (

{item?.photos.map((_: any, index: number) => ( setActiveSlide(index)} /> ))}
);

};

return ( <Carousel // ref={(c) => { this._carousel = c; }} // autoplay={true} data={item?.photos} renderItem={({item}: any) => ( <ImageBackground style={styles.imageBackground} source={{uri: item}}>

              </ImageBackground>
            )}
            layout={'default'}
            sliderWidth={R.unit.windowWidth()}
            itemWidth={R.unit.windowWidth()}
            onSnapToItem={index => setActiveSlide(index)}
          />
          {renderPagination()}

)