From a16edcb7e49442b20f96499e182e6eec50a9632a Mon Sep 17 00:00:00 2001 From: Shiv Bhonde Date: Tue, 16 Jul 2024 23:56:48 +0900 Subject: [PATCH] fix: chains not updated after delted --- .../nextjs/components/NetworksDropdown/NetworksDropdown.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/nextjs/components/NetworksDropdown/NetworksDropdown.tsx b/packages/nextjs/components/NetworksDropdown/NetworksDropdown.tsx index dd527832..eae6ea37 100644 --- a/packages/nextjs/components/NetworksDropdown/NetworksDropdown.tsx +++ b/packages/nextjs/components/NetworksDropdown/NetworksDropdown.tsx @@ -14,6 +14,7 @@ import { import { useTheme } from "next-themes"; import Select, { MultiValue, SingleValue } from "react-select"; import { Chain } from "viem"; +import { mainnet } from "viem/chains"; import { AddCustomChainModal, CustomOption, OtherChainsModal } from "~~/components/NetworksDropdown"; import { useGlobalState } from "~~/services/store/store"; @@ -23,9 +24,10 @@ export const NetworksDropdown = ({ onChange }: { onChange: (options: any) => any const [groupedOptionsState, setGroupedOptionsState] = useState(initialGroupedOptions); const [selectedOption, setSelectedOption] = useState>(initialGroupedOptions.mainnet.options[0]); - const { addCustomChain, removeChain } = useGlobalState(state => ({ + const { addCustomChain, removeChain, resetTargetNetwork } = useGlobalState(state => ({ addCustomChain: state.addChain, removeChain: state.removeChain, + resetTargetNetwork: () => state.setTargetNetwork(mainnet), })); const seeOtherChainsModalRef = useRef(null); @@ -108,6 +110,7 @@ export const NetworksDropdown = ({ onChange }: { onChange: (options: any) => any removeChain(chainId); removeChainFromLocalStorage(chainId); + resetTargetNetwork(); const newGroupedOptions = { ...groupedOptionsState }; const groupName = option.testnet ? "testnet" : "mainnet";