Skip to content

Commit

Permalink
replaced legacy ref string with ref callback
Browse files Browse the repository at this point in the history
  • Loading branch information
benhowell committed Aug 22, 2016
1 parent 3df1dae commit a16fe43
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Gallery extends Component {
}

componentDidUpdate () {
if (this.refs.gallery.clientWidth
if (this._gallery.clientWidth
!== this.state.containerWidth){
this.handleResize();
}
Expand All @@ -46,7 +46,7 @@ class Gallery extends Component {
handleResize () {
this.setState({
containerWidth:
Math.floor(this.refs.gallery.clientWidth)
Math.floor(this._gallery.clientWidth)
});
}

Expand Down Expand Up @@ -167,7 +167,7 @@ class Gallery extends Component {
return items;
}

renderGallery () {
renderImages () {
if (!this.props.images) return;
if (this.state.containerWidth == 0) return;
var items = this.scaleThumbs(this.props.images.slice());
Expand Down Expand Up @@ -202,8 +202,8 @@ class Gallery extends Component {

render () {
return (
<div id="Gallery" ref="gallery">
{this.renderGallery()}
<div id="Gallery" ref={(c) => this._gallery = c}>
{this.renderImages()}
<Lightbox
images={this.props.images}
backdropClosesModal={this.props.backdropClosesModal}
Expand Down

0 comments on commit a16fe43

Please sign in to comment.