How to use the @magento/peregrine.useCarousel function in @magento/peregrine

To help you get started, we’ve selected a few @magento/peregrine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Jordaneisenburger / fallback-studio / src / pwa-studio / packages / venia-concept / src / components / ProductImageCarousel / carousel.js View on Github external
const Carousel = props => {
    const classes = mergeClasses(defaultClasses, props.classes);

    const [carouselState, carouselApi] = useCarousel(props.images);
    const { activeItemIndex, sortedImages } = carouselState;
    const { handlePrevious, handleNext, setActiveItemIndex } = carouselApi;

    const handleThumbnailClick = useCallback(
        index => {
            setActiveItemIndex(index);
        },
        [setActiveItemIndex]
    );

    const currentImage = sortedImages[activeItemIndex] || {};

    const src = currentImage.file
        ? resourceUrl(currentImage.file, {
              type: 'image-product',
              width: DEFAULT_IMAGE_WIDTH,