Skip to content

Commit

Permalink
fix: ensure import account component state is not shared across chains
Browse files Browse the repository at this point in the history
  • Loading branch information
woodenfurniture committed May 4, 2024
1 parent 2b04e66 commit 64805d1
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ export const ImportAccounts = ({ chainId, onClose }: ImportAccountsProps) => {
const [autoFetching, setAutoFetching] = useState(true)
const [toggledActiveAccountIds, setToggledActiveAccountIds] = useState<Set<AccountId>>(new Set())

// reset component state when chainId changes
useEffect(() => {
setAutoFetching(true)
setToggledActiveAccountIds(new Set())
}, [chainId])

// initial fetch to detect the number of accounts based on the "first empty account" heuristic
const {
data: accounts,
Expand Down Expand Up @@ -263,9 +269,10 @@ export const ImportAccounts = ({ chainId, onClose }: ImportAccountsProps) => {
if (!asset || !accounts) return null
return accounts.pages.map(({ accountIdWithActivityAndMetadata }, accountNumber) => {
const accountIds = accountIdWithActivityAndMetadata.map(({ accountId }) => accountId)
const key = accountIds.join('-')
return (
<TableRow
key={accountNumber}
key={key}
accountNumber={accountNumber}
accountIds={accountIds}
asset={asset}
Expand Down

0 comments on commit 64805d1

Please sign in to comment.