Fix linter problems
This commit is contained in:
@@ -48,43 +48,48 @@ export default class OnlineValidatorBadge extends React.Component {
|
|||||||
|
|
||||||
|
|
||||||
class ValidatorImage extends React.Component {
|
class ValidatorImage extends React.Component {
|
||||||
|
static propTypes = {
|
||||||
|
src: PropTypes.string,
|
||||||
|
alt: PropTypes.string
|
||||||
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props)
|
||||||
this.state = {
|
this.state = {
|
||||||
loaded: false,
|
loaded: false,
|
||||||
error: false
|
error: false
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const img = new Image();
|
const img = new Image()
|
||||||
img.onload = () => {
|
img.onload = () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
loaded: true
|
loaded: true
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
img.onerror = () => {
|
img.onerror = () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
error: true
|
error: true
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
img.src = this.props.src;
|
img.src = this.props.src
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
if (nextProps.src !== this.props.src) {
|
if (nextProps.src !== this.props.src) {
|
||||||
const img = new Image();
|
const img = new Image()
|
||||||
img.onload = () => {
|
img.onload = () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
loaded: true
|
loaded: true
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
img.onerror = () => {
|
img.onerror = () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
error: true
|
error: true
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
img.src = nextProps.src;
|
img.src = nextProps.src
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user