From 87517f806d3afc4202ec7919ff75d6c3b3d490dd Mon Sep 17 00:00:00 2001 From: Jiexi Luan Date: Thu, 16 Jan 2025 08:30:23 -0800 Subject: [PATCH] Fix edit accounts modal and edit network modal checkbox reset on rerender --- .../multichain/edit-accounts-modal/edit-accounts-modal.tsx | 5 ++++- .../multichain/edit-networks-modal/edit-networks-modal.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ui/components/multichain/edit-accounts-modal/edit-accounts-modal.tsx b/ui/components/multichain/edit-accounts-modal/edit-accounts-modal.tsx index ddc2749e2ee7..4343b646052d 100644 --- a/ui/components/multichain/edit-accounts-modal/edit-accounts-modal.tsx +++ b/ui/components/multichain/edit-accounts-modal/edit-accounts-modal.tsx @@ -60,7 +60,10 @@ export const EditAccountsModal: React.FC = ({ useEffect(() => { setSelectedAccountAddresses(defaultSelectedAccountAddresses); - }, [defaultSelectedAccountAddresses]); + }, [ + // TODO: Fix the source of this prop value to be the same array instance each render + JSON.stringify(defaultSelectedAccountAddresses), + ]); const selectAll = () => { const allNetworksAccountAddresses = accounts.map(({ address }) => address); diff --git a/ui/components/multichain/edit-networks-modal/edit-networks-modal.js b/ui/components/multichain/edit-networks-modal/edit-networks-modal.js index 0b86716af50a..ba10e2bc9a02 100644 --- a/ui/components/multichain/edit-networks-modal/edit-networks-modal.js +++ b/ui/components/multichain/edit-networks-modal/edit-networks-modal.js @@ -52,7 +52,10 @@ export const EditNetworksModal = ({ useEffect(() => { setSelectedChainIds(defaultSelectedChainIds); - }, [defaultSelectedChainIds]); + }, [ + // TODO: Fix the source of this prop value to be the same array instance each render + JSON.stringify(defaultSelectedChainIds), + ]); const selectAll = () => { const allNetworksChainIds = allNetworks.map(({ chainId }) => chainId);