()
| 34 | const CarouselContext = React.createContext<CarouselContextProps | null>(null); |
| 35 | |
| 36 | function useCarousel() { |
| 37 | const context = React.useContext(CarouselContext); |
| 38 | |
| 39 | if (!context) { |
| 40 | throw new Error("useCarousel must be used within a <Carousel />"); |
| 41 | } |
| 42 | |
| 43 | return context; |
| 44 | } |
| 45 | |
| 46 | const Carousel = React.forwardRef< |
| 47 | HTMLDivElement, |