Skip to content
This repository was archived by the owner on Jan 19, 2023. It is now read-only.

Commit d1be1f9

Browse files
committed
Make fixes for [email protected]
1 parent 2e8fc2a commit d1be1f9

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"react-modal": "^1.4.0"
3434
},
3535
"peerDependencies": {
36+
"prop-types": "^15.5.8",
3637
"react": "^15.0.0",
3738
"react-dom": "^15.0.0"
3839
},
@@ -58,6 +59,7 @@
5859
"html-webpack-plugin": "^2.22.0",
5960
"node-sass": "^3.8.0",
6061
"postcss-loader": "^1.1.0",
62+
"prop-types": "^15.5.8",
6163
"react": "^15.2.0",
6264
"react-dom": "^15.2.0",
6365
"react-hot-loader": "^1.3.0",

src/examples/cats/app.js

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { Component } from 'react';
22
import ReactDOM from 'react-dom';
33
import Lightbox from '../../react-image-lightbox';
44
import styles from './stylesheets/app.scss';
@@ -81,28 +81,41 @@ const captions = [
8181
'',
8282
];
8383

84-
const App = React.createClass({
85-
getInitialState() {
86-
return {
84+
class App extends Component {
85+
constructor() {
86+
super();
87+
88+
this.state = {
8789
index: 0,
8890
isOpen: false
8991
};
90-
},
92+
93+
this.openLightbox = this.openLightbox.bind(this);
94+
this.closeLightbox = this.closeLightbox.bind(this);
95+
this.moveNext = this.moveNext.bind(this);
96+
this.movePrev = this.movePrev.bind(this);
97+
}
98+
9199
openLightbox() {
92100
this.setState({ isOpen: true });
93-
},
101+
}
102+
94103
closeLightbox() {
95104
this.setState({ isOpen: false });
96-
},
105+
}
106+
97107
moveNext() {
98108
this.setState({ index: (this.state.index + 1) % images.length });
99-
},
109+
}
110+
100111
movePrev() {
101112
this.setState({ index: (this.state.index + images.length - 1) % images.length });
102-
},
103-
onImageLoadError(imageSrc, _srcType, errorEvent) {
113+
}
114+
115+
static onImageLoadError(imageSrc, _srcType, errorEvent) {
104116
console.error(`Could not load image at ${imageSrc}`, errorEvent); // eslint-disable-line no-console
105-
},
117+
}
118+
106119
render() {
107120
let lightbox;
108121
if (this.state.isOpen) {
@@ -119,7 +132,7 @@ const App = React.createClass({
119132
onCloseRequest={this.closeLightbox}
120133
onMovePrevRequest={this.movePrev}
121134
onMoveNextRequest={this.moveNext}
122-
onImageLoadError={this.onImageLoadError}
135+
onImageLoadError={App.onImageLoadError}
123136

124137
imageTitle={titles[this.state.index]}
125138
imageCaption={captions[this.state.index]}
@@ -191,6 +204,6 @@ const App = React.createClass({
191204
</div>
192205
);
193206
}
194-
});
207+
}
195208

196209
ReactDOM.render(<App />, document.getElementById('app'));

src/react-image-lightbox.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
* @license Open source under the MIT License
55
*/
66

7-
import React, { Component, PropTypes } from 'react';
7+
import React, { Component } from 'react';
8+
import PropTypes from 'prop-types';
89
import Modal from 'react-modal';
910
import {
1011
translate,

0 commit comments

Comments
 (0)