Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8c1d69b

Browse files
authored
Merge pull request #3 from kirkness/master
Check if mounted before continuing loop
2 parents e87d8fc + 4d42deb commit 8c1d69b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

‎src/index.js‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ export default class SvgAnimatedLinearGradient extends Component {
1919
],
2020
frequence: props.duration / 2
2121
}
22+
this._isMounted = false;
2223
this._animate = new Animated.Value(0)
2324
this.loopAnimation = this
2425
.loopAnimation
2526
.bind(this)
26-
}
27+
}
2728
offsetValueBound(x) {
2829
if (x > 1) {
2930
return '1'
@@ -34,11 +35,14 @@ export default class SvgAnimatedLinearGradient extends Component {
3435
return x
3536
}
3637
componentDidMount(props) {
38+
this._isMounted = true
3739
this.loopAnimation()
3840
}
39-
41+
componentWillUnmount() {
42+
this._isMounted = false
43+
}
4044
loopAnimation() {
41-
45+
if(!this._isMounted)return;
4246
// setup interpolate
4347
let interpolator = interpolate(this.state, {
4448
offsetValues: ['1', '1.5', '2']

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /