mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 08:55:24 +00:00
Only re-render the org logo when src is changed (#779)
This commit is contained in:
parent
3a6a32a645
commit
e9cc3e3a13
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user