Skip to content

Commit

Permalink
fix setTimeout maybe invoked after unmount.
Browse files Browse the repository at this point in the history
  • Loading branch information
maoziliang committed Aug 3, 2015
1 parent 3483b80 commit 1754c0d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/refresh-indicator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ const RefreshIndicator = React.createClass({
},

_scalePath(path, step) {
if (this.props.status !== 'loading') return;
if (this.props.status !== 'loading' || !this.isMounted()) return;

const currStep = (step || 0) % 3;

Expand All @@ -239,7 +239,7 @@ const RefreshIndicator = React.createClass({
},

_rotateWrapper(wrapper) {
if (this.props.status !== 'loading') return;
if (this.props.status !== 'loading' || !this.isMounted()) return;

clearTimeout(this._timer2);
this._timer2 = setTimeout(this._rotateWrapper.bind(this, wrapper), 10050);
Expand All @@ -249,9 +249,11 @@ const RefreshIndicator = React.createClass({
AutoPrefix.set(wrapper.style, "transitionDuration", "0ms");

setTimeout(() => {
AutoPrefix.set(wrapper.style, "transform", "rotate(1800deg)");
wrapper.style.transitionDuration = "10s";
AutoPrefix.set(wrapper.style, "transitionTimingFunction", "linear");
if (this.isMounted()) {
AutoPrefix.set(wrapper.style, "transform", "rotate(1800deg)");
wrapper.style.transitionDuration = "10s";
AutoPrefix.set(wrapper.style, "transitionTimingFunction", "linear");
}
}, 50);
},

Expand Down

0 comments on commit 1754c0d

Please sign in to comment.