Replies: 2 comments
-
Hi You can find example in our README import { Gallery } from 'react-photoswipe-gallery'
const onOpen = (pswpInstance) => {
console.log('photoswipe was opened')
fetch('https://example.com')
pswpInstance.on('close', () => {
console.log('photoswipe was closed')
})
}
const MyGallery = () => (
<Gallery onOpen={onOpen}>
{/*...*/}
</Gallery>
) if you need some state, that will store open photoswipe or not, you can create it yourself import React, { useState } from 'react'
import { Gallery } from 'react-photoswipe-gallery'
const [isOpen, setIsOpen] = useState(false)
const onOpen = (pswpInstance) => {
setIsOpen(true)
console.log('photoswipe was opened')
fetch('https://example.com')
pswpInstance.on('close', () => {
setIsOpen(false)
console.log('photoswipe was closed')
})
}
const MyGallery = () => (
<Gallery onOpen={onOpen}>
{/*...*/}
</Gallery>
) |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi i have question how to get access to gallery open prop? For example i want to fetch data on Gallery open and i need the open prop to put it in useEffect dependecy array. Also i would like to know how to know when gallery closes something like onClose method.
Beta Was this translation helpful? Give feedback.
All reactions