mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 01:47:00 +01:00
Cleanup: clearTimeout on useEffect for gas estimation and prevent state update on unmounted ConfirmTransactionBase (#17804)
This commit is contained in:
parent
962a861808
commit
7d1dc7f177
@ -44,13 +44,18 @@ export function useShouldAnimateGasEstimations() {
|
|||||||
}, [dispatch, isGasLoadingAnimationActive, showLoadingAnimation]);
|
}, [dispatch, isGasLoadingAnimationActive, showLoadingAnimation]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
let timer;
|
||||||
isGasLoadingAnimationActive === true &&
|
|
||||||
showLoadingAnimation === false
|
if (isGasLoadingAnimationActive && !showLoadingAnimation) {
|
||||||
) {
|
timer = setTimeout(() => {
|
||||||
setTimeout(() => {
|
|
||||||
dispatch(toggleGasLoadingAnimation(false));
|
dispatch(toggleGasLoadingAnimation(false));
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (timer) {
|
||||||
|
clearTimeout(timer);
|
||||||
|
}
|
||||||
|
};
|
||||||
}, [dispatch, isGasLoadingAnimationActive, showLoadingAnimation]);
|
}, [dispatch, isGasLoadingAnimationActive, showLoadingAnimation]);
|
||||||
}
|
}
|
||||||
|
@ -866,6 +866,10 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
sendTransaction(txData)
|
sendTransaction(txData)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
clearConfirmTransaction();
|
clearConfirmTransaction();
|
||||||
|
if (!this._isMounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.setState(
|
this.setState(
|
||||||
{
|
{
|
||||||
submitting: false,
|
submitting: false,
|
||||||
@ -877,6 +881,10 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
if (!this._isMounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
submitting: false,
|
submitting: false,
|
||||||
submitError: error.message,
|
submitError: error.message,
|
||||||
|
Loading…
Reference in New Issue
Block a user