mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 01:18:42 +00:00
Only re-render the org logo when src is changed (#779)
This commit is contained in:
parent
3a6a32a645
commit
e9cc3e3a13
1 changed files with 23 additions and 0 deletions
|
|
@ -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 a new issue