<div id="app"></div>
const photos = [
  {src: 'https://source.unsplash.com/2ShvY8Lf6l0/800x599', width:4, height:3},
  {src: 'https://source.unsplash.com/Dm-qxdynoEc/800x799', width:1, height:1},
  {src: 'https://source.unsplash.com/qDkso9nvCg0/600x799', width:3, height:4},
  {src: 'https://source.unsplash.com/iecJiKe_RNg/600x799', width:3, height:4},
  {src: 'https://source.unsplash.com/epcsn8Ed8kY/600x799', width:3, height:4},
  {src: 'https://source.unsplash.com/NQSWvyVRIJk/800x599', width:4, height:3},
  {src: 'https://source.unsplash.com/zh7GEuORbUw/600x799', width:3, height:4},
  {src: 'https://source.unsplash.com/PpOHJezOalU/800x599', width:4, height:3},
  {src: 'https://source.unsplash.com/I1ASdgphUH4/800x599', width:4, height:3}
];

class App extends React.Component{
  constructor(){             
    super();                 
    this.state = { currentImage: 0 }; 
    this.closeLightbox = this.closeLightbox.bind(this); 
    this.openLightbox = this.openLightbox.bind(this);
    this.gotoNext = this.gotoNext.bind(this);
    this.gotoPrevious = this.gotoPrevious.bind(this);
  }
  openLightbox(event, obj) {
    console.log('open')
    this.setState({
      currentImage: obj.index,
      lightboxIsOpen: true,
    });  
  }
  closeLightbox() {
    this.setState({
      currentImage: 0,
      lightboxIsOpen: false,
    }); 
  }
  gotoPrevious() {
    this.setState({
      currentImage: this.state.currentImage - 1,                                                           
    });  
  }
  gotoNext() {
    this.setState({
      currentImage: this.state.currentImage + 1,                                            
    }); 
  }
  render(){
    return(
      <div>
        <Gallery photos={photos} onClick={this.openLightbox} />
        <Lightbox images={photos}
          onClose={this.closeLightbox}
          onClickPrev={this.gotoPrevious}
          onClickNext={this.gotoNext}
          currentImage={this.state.currentImage}
          isOpen={this.state.lightboxIsOpen}
        />
      </div>
    )
  }
}
ReactDOM.render(<App />, document.getElementById('app'));
View Compiled
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/react/15.6.0/react.min.js
  2. https://cdnjs.cloudflare.com/ajax/libs/react/15.6.0/react-dom.min.js
  3. https://unpkg.com/prop-types@15.6.0/prop-types.js
  4. https://unpkg.com/react-photo-gallery@6.0.12/dist/react-photo-gallery.min.js
  5. https://unpkg.com/aphrodite/dist/aphrodite.umd.min.js
  6. https://cdnjs.cloudflare.com/ajax/libs/react-transition-group/1.1.3/react-transition-group.js
  7. https://rawgit.com/neptunian/react-scrolllock/master/dist/react-scrolllock.min.js
  8. https://unpkg.com/react-images@0.5.10/dist/react-images.min.js