PhotoSwipe in ReactJs

1.4k views Asked by At

I'm trying to use PhotoSwipe in ReactJs component, and it doesn't work.

In sake of simplicity:

I've took all the html from here and put it into render in react component. All the js i've put into ComponentDidMount method.

I'm pushing on the image caption and getting Uncaught TypeError: undefined is not a function on gallery.init(); All class changed to className as well as all itemScope, itemType, itemProp, tabIndex What is wrong?

1

There are 1 answers

0
AudioBubble On

In react you have to build component before you can do 'ComponentDidMount'. So render your html in a react component. like this :

var something = React.createClass ({

  render : function () {
      return(
          <div>
              //Your html code here
          </div>
      )
   }
});

After that you can work with the something component.