diff --git a/types/react-image-gallery/index.d.ts b/types/react-image-gallery/index.d.ts index 5b10b5925b..45de6e4d0a 100644 --- a/types/react-image-gallery/index.d.ts +++ b/types/react-image-gallery/index.d.ts @@ -79,7 +79,7 @@ declare class ReactImageGallery extends React.Component fullScreen: () => void; exitFullScreen: () => void; slideToIndex: (index: number) => void; - getCurrentIndex: () => void; + getCurrentIndex: () => number; } export default ReactImageGallery; diff --git a/types/react-image-gallery/react-image-gallery-tests.tsx b/types/react-image-gallery/react-image-gallery-tests.tsx index 65fedd7828..04e7d6a6f9 100644 --- a/types/react-image-gallery/react-image-gallery-tests.tsx +++ b/types/react-image-gallery/react-image-gallery-tests.tsx @@ -2,6 +2,14 @@ import * as React from 'react'; import ReactImageGallery, { ReactImageGalleryItem, ReactImageGalleryProps } from 'react-image-gallery'; class ImageGallery extends React.Component { + private gallery: ReactImageGallery | null; + + componentDidMount() { + if (this.gallery) { + const message = `Showing ${this.gallery.getCurrentIndex() + 1}. image the gallery.`; + } + } + render() { const galleryItem: ReactImageGalleryItem = { original: 'http://localhost/logo.jpg', @@ -14,6 +22,6 @@ class ImageGallery extends React.Component { showFullscreenButton: false }; - return ; + return this.gallery = r} {...props} />; } }