Skip to content

Commit

Permalink
reload only when src is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
chilijung committed Sep 6, 2018
1 parent 8c5dd4e commit 6884861
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-loading-image",
"version": "0.4.2",
"version": "0.5.0",
"description": "A react image loader component",
"homepage": "",
"author": {
Expand Down
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export default class ImageLoader extends React.PureComponent<Props, State> {
}

componentWillReceiveProps(nextProps: Props) {
this.reload(nextProps);
// reload only when image src is changed.
if (this.props.src !== nextProps.src)
this.reload(nextProps);
}

componentDidMount() {
Expand Down

0 comments on commit 6884861

Please sign in to comment.