React Spring Carousel

Context

If you have complex and nested carousel item components and you need to access to some methods that the hook you're using expose and you don't like the prop drilling solution, both hooks expose a context that you can import. Through the context you can access to all the methods that the parent hook expose.

1
2  // import { useTransitionCarouselContext } from "react-spring-carousel";
3  import { useSpringCarouselContext } from "react-spring-carousel";
4
5  function Component() {
6    const { slideToPrevItem, slideToNextItem } = useSpringCarouselContext()
7
8    return (
9      <div>
10        Carousel item 1
11      </div>
12    )
13  }
14
The context can be only imported in components that are rendered inside the carousel or inside the thumbs containers.