mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-21 17:37:01 +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]);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
isGasLoadingAnimationActive === true &&
|
||||
showLoadingAnimation === false
|
||||
) {
|
||||
setTimeout(() => {
|
||||
let timer;
|
||||
|
||||
if (isGasLoadingAnimationActive && !showLoadingAnimation) {
|
||||
timer = setTimeout(() => {
|
||||
dispatch(toggleGasLoadingAnimation(false));
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
};
|
||||
}, [dispatch, isGasLoadingAnimationActive, showLoadingAnimation]);
|
||||
}
|
||||
|
@ -866,6 +866,10 @@ export default class ConfirmTransactionBase extends Component {
|
||||
sendTransaction(txData)
|
||||
.then(() => {
|
||||
clearConfirmTransaction();
|
||||
if (!this._isMounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState(
|
||||
{
|
||||
submitting: false,
|
||||
@ -877,6 +881,10 @@ export default class ConfirmTransactionBase extends Component {
|
||||
);
|
||||
})
|
||||
.catch((error) => {
|
||||
if (!this._isMounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({
|
||||
submitting: false,
|
||||
submitError: error.message,
|
||||
|
Loading…
Reference in New Issue
Block a user