I am trying to set it up so that when an image mapped from an array is scrolled, the state is updated with that image's coordinates thus updating the Google Map.
<CloudinaryContext cloudName="hcjmhcjf" fetchFormat="auto">
<div className="image-holder">
{displayImages.map((displayImage, i) => {
return (
<div
className="responsive"
key={i}
ref="img"
onScroll={this.handleScroll(this.state.images[i].location)}>
<div className="img">
<a
target="_blank"
href={`http://res.cloudinary.com/gdbdtb/image/upload/${displayImage}.jpg`}>
<Image publicId={displayImage} responsive style={{width: '100%'}}>
<Transformation crop="scale" width="auto" responsive_placeholder="blank" />
</Image>
</a>
</div>
</div>
);
})}
</div>
</CloudinaryContext>
from reading through some other questions I set the following lifecycle methods up:
componentDidMount() {
const imgDiv = ReactDOM.findDOMNode(this.refs.img)
imgDiv.addEventListener('scroll', this.handleScroll);
}
componentWillUnmount() {
const imgDiv = ReactDOM.findDOMNode(this.refs.img)
imgDiv.removeEventListener('scroll', this.handleScroll);
}
however, ReactDOM.findDOMNode(this.refs.img)
always returns undefined
What would be a way that I could call
handleScroll(location) {
this.setState({
center: location
})
}
and have the map update when a specific image is scrolled?