Skip to content

Commit 72093a1

Browse files
authored
Merge pull request #84 from nick-codes/fix-get-node-while-unmounted
Fix Issue #83: Issue with event firing on unmounted component.
2 parents 078555e + 32dcb5e commit 72093a1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/LazyLoad.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default class LazyLoad extends Component {
2424
}
2525

2626
componentDidMount() {
27+
this._mounted = true;
2728
const eventNode = this.getEventNode();
2829

2930
this.lazyLoadHandler();
@@ -47,6 +48,7 @@ export default class LazyLoad extends Component {
4748
}
4849

4950
componentWillUnmount() {
51+
this._mounted = false;
5052
if (this.lazyLoadHandler.cancel) {
5153
this.lazyLoadHandler.cancel();
5254
}
@@ -77,6 +79,9 @@ export default class LazyLoad extends Component {
7779
}
7880

7981
lazyLoadHandler() {
82+
if (!this._mounted) {
83+
return;
84+
}
8085
const offset = this.getOffset();
8186
const node = findDOMNode(this);
8287
const eventNode = this.getEventNode();

0 commit comments

Comments
 (0)