useCarousel
The useCarousel hook is used inside the Carousel component. This hook handles the slider logic, inside the Carousel component.
This hook is an internal hook and is not available for the users since it's not exposed as a part of this library.
Code
Explanation
As you can see above it uses the useState hook of the React internally for managing the state of slider on arrow click.
It accepts two parameters - a
initialValue
, which is an integer (default value is zero) andimagesListLength
- the array length containing source links for each image.It returns the following:
currentSlide
- index of the current slide.handleLeftArrow
- function to manage previous button click.handleRightArrow
- function to manage right button click.
Last updated