RSCJS - React Spring Carousel JS

Context

It may happen that you have complex and nested carousel item components and you need to access to some methods that the library expose and you don't like the prop drilling solution. If that's your case, the library also expose a context that you can import. Through the context you can access to all the methods that the main hook expose.

The context can be only imported in components inside the carousel or inside the thumbs containers.

1import { useContext } from "react";
2import { useSpringCarouselContext } from "react-spring-carousel-js";
3
4const Component = () => {
5  const { slideToPrevItem, slideToNextItem } = useSpringCarouselContext()
6
7  return (
8    <div>
9      Carousel item 1
10    </div>
11  )
12}
13