YIZHUANG / react-multi-carousel

A lightweight production-ready Carousel that rocks supports multiple items and server-side rendering with no dependency. Bundle size 2kb.
MIT License
1.25k stars 286 forks source link

How to connect my custom buttons tp prev() and next() functions in react-multi-carousel #305

Closed ssomlk closed 2 years ago

ssomlk commented 2 years ago

Prerequisite

Before you submit a feature request or report a bug to be fixed, make sure you have stared this repository. A donation is also welcomed

Describe the bug Please note that this is not a bug. Need some help with integrating react-multi-carousel into my NextJs project

To Reproduce Steps to reproduce the behavior: I have installed react-multi-carousel Have imported the relevant css as mentioned in the document and the carousel is working totally fine. I am trying to remove the left and right arrows from carousel. (This was possible) I have introduced my custom buttons. How can i connect the two buttons to the same functions next() and previous() using inside react-multi-carousel

Some insight would be great on this

Trying something like below. But how can i access the existing next, previous functions and pass inside CustomButtonGroup

const CustomButtonGroup = ({ next, previous, goToSlide, carouselState }) => { const { totalItems, currentSlide } = carouselState; return (

Current slide is {currentSlide}

); };

JanKochEmpiriecom commented 2 years ago

A CustomButtonGroup is a react component. It will be used if you give these component into the carousel with the "customButtonGroup" prop.

The CustomButtonGroup component recieves the props "next, previous, goToSlide, carouselState" from the carousel component. You can find an example of such a component here: https://github.com/YIZHUANG/react-multi-carousel/blob/master/stories/CustomArrows.js

The component will be used here in line 396: https://github.com/YIZHUANG/react-multi-carousel/blob/master/stories/index.stories.js