joe223 / tiny-swiper

Ingenious JavaScript Carousel powered by wonderful plugins. Lightweight yet extensible. Import plugins as needed, No more, no less.
https://tiny-swiper.js.org
1.29k stars 58 forks source link

typescript? #52

Closed lorof closed 3 years ago

lorof commented 3 years ago
import Swiper from 'tiny-swiper';
import { useMount, useUnmount } from 'react-use';

export const Carousel: React.FC<CarouselProps> = (props) => {
  const containerRef = useRef<HTMLDivElement>(null);
  const swiperInstanceRef = useRef<typeof Swiper | null>(null);

  useMount(() => {
    if (!containerRef.current) return;

    swiperInstanceRef.current = new Swiper(containerRef.current, {
      pagination: {
        clickable: true
      }
    });
  });
}

Image of swiper