forked from pterolex/react-components
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImage.jsx
More file actions
41 lines (34 loc) · 769 Bytes
/
Image.jsx
File metadata and controls
41 lines (34 loc) · 769 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
35
36
37
38
39
40
41
/**
* @jsx React.DOM
*/
'use strict';
var React = require('react');
var Image = React.createClass({
propTypes: {
src: React.PropTypes.string,
placeholder: React.PropTypes.object // DOM ELEMENT
},
getDefaultProps() {
return {
placeholder: (<div />)
};
},
getInitialState() {
return {
src: this.props.src
};
},
handleImageLoadError() {
this.setState({
src: undefined
});
},
render() {
return this.state.src
? <img className='WLC-Image'
src={this.state.src}
onError={this.handleImageLoadError} />
: this.props.placeholder;
}
});
module.exports = Image;