Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import type { AccountJson } from '@polkadot/extension-base/background/types';
import { Box, Container, Stack } from '@mui/material';
import { AddCircle, Trash } from 'iconsax-react';
import React, { memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
import { useNavigate } from 'react-router-dom';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: useNavigate is not available in react-router-dom v5.3.3.

The project uses react-router-dom v5.3.3, but useNavigate is a v6+ API. This import will fail at runtime.

Based on learnings.

Use the v5 equivalent instead:

-import { useNavigate } from 'react-router-dom';
+import { useHistory } from 'react-router-dom';

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In packages/extension-polkagate/src/popup/accountsLists/BodySection.tsx around
line 9, the code imports useNavigate which is a react-router-dom v6 API and will
fail at runtime with v5.3.3; replace the import with useHistory from
'react-router-dom' and update any navigation calls to use history.push(...) or
history.replace(...) accordingly (obtain history via const history =
useHistory() and use history.push/replace where useNavigate() would have been
used).


import { windowOpen } from '@polkadot/extension-polkagate/src/messaging';
import { PROFILE_TAGS } from '@polkadot/extension-polkagate/src/util/constants';

import { AccountContext, ActionButton, ActionContext, FadeOnScroll, GradientButton, MyTooltip } from '../../components';
import { AccountContext, ActionButton, FadeOnScroll, GradientButton, MyTooltip } from '../../components';
import { AccountProfileLabel } from '../../fullscreen/components';
import { useCategorizedAccountsInProfiles, useSelectedAccount, useTranslation } from '../../hooks';
import { VelvetBox } from '../../style';
Expand Down Expand Up @@ -48,7 +49,7 @@ interface Props {
function BodySection ({ mode, onApply, searchKeyword, setMode, setShowDeleteConfirmation }: Props): React.ReactElement {
const { t } = useTranslation();
const { accounts: flatAccounts } = useContext(AccountContext);
const onAction = useContext(ActionContext);
const navigate = useNavigate();
const refContainer = useRef<HTMLDivElement>(null);
const selectedAccount = useSelectedAccount();
const { categorizedAccounts: initialCategorizedAccounts } = useCategorizedAccountsInProfiles();
Expand All @@ -64,9 +65,9 @@ function BodySection ({ mode, onApply, searchKeyword, setMode, setShowDeleteConf

useEffect(() => {
if (flatAccounts.length === 0) { // when all accounts/profiles are deleted
onAction('/');
navigate('/') as void;
}
}, [flatAccounts.length, onAction]);
}, [flatAccounts.length, navigate]);

const onCreateClick = useCallback(() => {
windowOpen('/account/create').catch(console.error);
Expand Down Expand Up @@ -103,7 +104,7 @@ function BodySection ({ mode, onApply, searchKeyword, setMode, setShowDeleteConf
<BackDrop setMode={setMode} />
}
<Container disableGutters sx={{ display: 'block', height: 'fit-content', maxHeight: 'calc(100% - 50px)', minHeight: '453px', pb: '50px', position: 'relative', width: 'initial', zIndex: 1 }}>
<VelvetBox style={{ margin: '5px 0 15px' }}>
<VelvetBox childrenStyle={{ borderRadius: '16px', overflow: 'hidden' }} style={{ margin: '5px 0 15px' }}>
<Stack ref={refContainer} style={{ maxHeight: '380px', minHeight: '88px', overflow: 'hidden', overflowY: 'auto', position: 'relative' }}>
{Object.keys(filteredCategorizedAccounts).length > 0 && (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function AccountsListManagement ({ defaultMode = PROFILE_MODE.NONE, onDon

function AccountsLists (): React.ReactElement {
return (
<Grid alignContent='flex-start' container sx={{ height: '100%', position: 'relative' }}>
<Grid alignContent='flex-start' container sx={{ height: '100%', overflow: 'hidden', position: 'relative' }}>
<UserDashboardHeader homeType='default' />
<AccountsListManagement />
</Grid>
Expand Down
Loading