From e9cc3e3a1381c90e81d85a742cb938f88fa8a7b1 Mon Sep 17 00:00:00 2001 From: Mike Stone Date: Fri, 6 Jan 2017 13:45:37 -0500 Subject: [PATCH] Only re-render the org logo when src is changed (#779) --- .../icons/OrgLogoIcon/OrgLogoIcon.jsx | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/frontend/components/icons/OrgLogoIcon/OrgLogoIcon.jsx b/frontend/components/icons/OrgLogoIcon/OrgLogoIcon.jsx index 2e1c3f3b6d..5ab62fc74a 100644 --- a/frontend/components/icons/OrgLogoIcon/OrgLogoIcon.jsx +++ b/frontend/components/icons/OrgLogoIcon/OrgLogoIcon.jsx @@ -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;