mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-09 01:13:41 +08:00
fix: clean timeout when componentWillUnmount in PaymentResult page (#1962)
This commit is contained in:
@ -25,6 +25,7 @@ class PaymentResultPage extends React.Component {
|
|||||||
classes: props,
|
classes: props,
|
||||||
paymentName: props.match.params.paymentName,
|
paymentName: props.match.params.paymentName,
|
||||||
payment: null,
|
payment: null,
|
||||||
|
timeout: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,6 +33,12 @@ class PaymentResultPage extends React.Component {
|
|||||||
this.getPayment();
|
this.getPayment();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
if (this.state.timeout !== null) {
|
||||||
|
clearTimeout(this.state.timeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getPayment() {
|
getPayment() {
|
||||||
PaymentBackend.getPayment("admin", this.state.paymentName)
|
PaymentBackend.getPayment("admin", this.state.paymentName)
|
||||||
.then((payment) => {
|
.then((payment) => {
|
||||||
@ -40,7 +47,7 @@ class PaymentResultPage extends React.Component {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (payment.state === "Created") {
|
if (payment.state === "Created") {
|
||||||
setTimeout(() => this.getPayment(), 1000);
|
this.setState({timeout: setTimeout(() => this.getPayment(), 1000)});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user