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