-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageCard.js
More file actions
34 lines (24 loc) · 802 Bytes
/
ImageCard.js
File metadata and controls
34 lines (24 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import React from 'react'
class ImageCard extends React.Component{
constructor(props) {
super ()
this.state ={spans:0}
this.imageRef = React.createRef()
}
componentDidMount() {
this.imageRef.current.addEventListener('load',this.setSpans)
}
setSpans=()=>{
const height =this.imageRef.current.clientHeight
const spans = Math.ceil(height/10 +1)
this.setState({spans})
}
render(){
const {description,urls} =this.props.image
return (
<div style={{gridRowEnd:`span ${this.state.spans}`}}>
<img ref={this.imageRef} alt={description} src={urls.reguler} />
</div>)
}
}
export default ImageCard