From 2a9a61fe14e451446dfe29005eb4aa6875cdbadc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Janto=C5=A1ovi=C4=8D?= Date: Thu, 22 Mar 2018 12:12:14 +0100 Subject: [PATCH] [react-image-gallery] getCurrentIndex() returns number --- types/react-image-gallery/index.d.ts | 2 +- .../react-image-gallery/react-image-gallery-tests.tsx | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) 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} />; } }