Skip to content

Commit

Permalink
update lightbox eg
Browse files Browse the repository at this point in the history
  • Loading branch information
neptunian committed Jun 21, 2019
1 parent 92d5633 commit d6b624d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions examples/src/ExampleWithLightbox.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import React, { useState } from "react";
import ReactDOM from "react-dom";
import Gallery from "react-photo-gallery";
import Carousel, { Modal, ModalGateway } from "react-images";
import React, { useState, useCallback } from 'react';
import ReactDOM from 'react-dom';
import Gallery from 'react-photo-gallery';
import Carousel, { Modal, ModalGateway } from 'react-images';

function ExampleWithLightbox({ photos }) {
const [currentImage, setCurrentImage] = useState(0);
const [viewerIsOpen, setViewerIsOpen] = useState(false);

const openLightbox = (event, obj) => {
const openLightbox = useCallback((event, obj) => {
setCurrentImage(obj.index);
setViewerIsOpen(true);
};
}, []);

const closeLightbox = () => {
setCurrentImage(0);
setViewerIsOpen(false);
Expand All @@ -28,7 +29,7 @@ function ExampleWithLightbox({ photos }) {
views={photos.map(x => ({
...x,
srcset: x.srcSet,
caption: x.title
caption: x.title,
}))}
/>
</Modal>
Expand Down

0 comments on commit d6b624d

Please sign in to comment.