Only re-render the org logo when src is changed (#779)

This commit is contained in:
Mike Stone 2017-01-06 13:45:37 -05:00 committed by GitHub
parent 3a6a32a645
commit e9cc3e3a13

View File

@ -28,18 +28,41 @@ class OrgLogoIcon extends Component {
componentWillReceiveProps (nextProps) {
const { src } = nextProps;
const { unchangedSourceProp } = this;
if (unchangedSourceProp(nextProps)) {
return false;
}
this.setState({ imageSrc: src });
return false;
}
shouldComponentUpdate (nextProps) {
const { imageSrc } = this.state;
const { unchangedSourceProp } = this;
if (unchangedSourceProp(nextProps) && (imageSrc === kolideLogo)) {
return false;
}
return true;
}
onError = () => {
this.setState({ imageSrc: kolideLogo });
return false;
}
unchangedSourceProp = (nextProps) => {
const { src: nextSrcProp } = nextProps;
const { src } = this.props;
return src === nextSrcProp;
}
render () {
const { className } = this.props;
const { imageSrc } = this.state;