Skip to content

Commit 3cf79a6

Browse files
committed
refactor: resolve race condition in Home navigation with v5-compat
1 parent 20d2209 commit 3cf79a6

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

ui/components/app/srp-quiz-modal/SRPQuiz/SRPQuiz.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports, import/no-commonjs */
22
import React, { useCallback, useContext, useEffect, useState } from 'react';
33
import { useSelector } from 'react-redux';
4-
import type { NavigateFunction } from 'react-router-dom-v5-compat';
54
import {
65
MetaMetricsEventCategory,
76
MetaMetricsEventKeyType,
@@ -64,7 +63,14 @@ export type SRPQuizProps = {
6463
isOpen: boolean;
6564
onClose: () => void;
6665
closeAfterCompleting?: boolean;
67-
navigate: NavigateFunction;
66+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
67+
navigate: (
68+
to: any,
69+
options?: {
70+
replace?: boolean;
71+
state?: Record<string, unknown>;
72+
},
73+
) => void;
6874
};
6975

7076
// TODO: Fix in https://github.com/MetaMask/metamask-extension/issues/31860

ui/components/multichain/account-details/account-details.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,13 @@ import { AccountDetailsKey } from './account-details-key';
5151

5252
type AccountDetailsProps = {
5353
address: string;
54+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5455
navigate?: (
55-
to: string | number,
56-
options?: { replace?: boolean; state?: Record<string, unknown> },
56+
to: any,
57+
options?: {
58+
replace?: boolean;
59+
state?: Record<string, unknown>;
60+
},
5761
) => void;
5862
};
5963

ui/pages/confirmations/confirm-transaction/confirm-transaction.component.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,8 @@ const ConfirmTransaction = ({
174174
dispatch(getContractMethodData(data, use4ByteResolution));
175175
}
176176
} else if (prevTransactionId && !transactionId && !totalUnapproved) {
177-
dispatch(setDefaultHomeActiveTabName('activity')).then(() => {
178-
navigate(DEFAULT_ROUTE, { replace: true });
179-
});
177+
dispatch(setDefaultHomeActiveTabName('activity'));
178+
navigate(DEFAULT_ROUTE, { replace: true });
180179
} else if (
181180
prevTransactionId &&
182181
transactionId &&

ui/pages/routes/routes.component.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -863,11 +863,17 @@ export default function Routes() {
863863
})}
864864
</Route>
865865
<Route path={`${CONFIRMATION_V_NEXT_ROUTE}/:id?`}>
866-
{createV5CompatRoute<{ id?: string }>(ConfirmationPage, {
867-
wrapper: AuthenticatedV5Compat,
868-
includeParams: true,
869-
paramsAsProps: false,
870-
})}
866+
{(props: RouteComponentProps<{ id?: string }>) => {
867+
const renderFn = createV5CompatRoute<{ id?: string }>(
868+
ConfirmationPage,
869+
{
870+
wrapper: AuthenticatedV5Compat,
871+
includeParams: true,
872+
paramsAsProps: false,
873+
},
874+
);
875+
return renderFn(props);
876+
}}
871877
</Route>
872878
<RouteWithLayout
873879
authenticated

0 commit comments

Comments
 (0)