mirror of
https://github.com/kevinsqi/react-circular-progressbar.git
synced 2026-01-18 15:55:06 +00:00
Merge pull request #2 from lokiuz/master
Fixes #1 - If the component is mounted and then unmounted immediately, its possible for the timeout to fire after unmounting leading React throwing a warning.
This commit is contained in:
commit
7026b2c8fb
@ -11,8 +11,8 @@ class CircularProgressbar extends React.Component {
|
||||
|
||||
componentDidMount() {
|
||||
if (this.props.initialAnimation) {
|
||||
setTimeout(() => {
|
||||
window.requestAnimationFrame(() => {
|
||||
this.initialTimeout = setTimeout(() => {
|
||||
this.requestAnimationFrame = window.requestAnimationFrame(() => {
|
||||
this.setState({
|
||||
percentage: this.props.percentage,
|
||||
});
|
||||
@ -27,6 +27,11 @@ class CircularProgressbar extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
clearTimeout(this.initialTimeout);
|
||||
window.cancelAnimationFrame(this.requestAnimationFrame);
|
||||
}
|
||||
|
||||
render() {
|
||||
const radius = (50 - this.props.strokeWidth / 2);
|
||||
const pathDescription = `
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user