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