Skip to content

Commit

Permalink
Check for any prop change before updating icon
Browse files Browse the repository at this point in the history
  • Loading branch information
divyanshu013 committed Jul 12, 2019
1 parent bb90163 commit dfbd304
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/ReactAnimatedWeather.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ class ReactAnimatedWeather extends React.Component {
}

componentWillReceiveProps(nextProps) {
// If color props match, don't reinitialize the icon
if (this.skyconIcon.color === nextProps.color) {
// If props match, don't reinitialize the icon
const { animate, icon } = this.props;
if (
this.skyconIcon.color === nextProps.color
&& animate === nextProps.animate
&& icon === nextProps.icon
) {
return;
}

Expand All @@ -45,9 +50,7 @@ class ReactAnimatedWeather extends React.Component {
const { size } = this.props;
return (
<canvas
ref={canvas => {
this.skycon = canvas;
}}
ref={(canvas) => { this.skycon = canvas; }}
width={size}
height={size}
/>
Expand Down

0 comments on commit dfbd304

Please sign in to comment.