Open gmpofficial opened 4 years ago
I had a similar requirement (show caption) and solved in this way:
import Gallery, {Photo} from "react-photo-gallery";
...
render(){
return (
<Gallery photos={PHOTOS} renderImage={this.imageRenderer} />
)
}
...
imageRenderer({ index, onClick, photo, margin, direction, top, left, key}) {
return (
<div>
<Photo key={key} index={index}
photo={photo} left={left} top={top} onClick={onClick} margin={margin} direction={direction} />
<p>{photo.title}</p>
</div>
)
}
@fciri Thanks for the idea! Any clue how to do this with TypeScript? I can't seem to import the named { Photo }
export. I looked inside index.d.ts
in the npm package, but I'm pretty lost.
import PhotoGallery, { Photo } from 'react-photo-gallery';
Module '"../../../../../node_modules/react-photo-gallery"' has no exported member 'Photo'.
(inherited this project, totally inexperienced with React)
Is there a way to overlay an image title over each image in the gallery? Example: