diff --git a/app/ts/components/subcomponents/ChainSelector.tsx b/app/ts/components/subcomponents/ChainSelector.tsx index 307d0749..be4fa64d 100644 --- a/app/ts/components/subcomponents/ChainSelector.tsx +++ b/app/ts/components/subcomponents/ChainSelector.tsx @@ -1,7 +1,7 @@ -import { useRef, useState } from 'preact/hooks' +import { useRef } from 'preact/hooks' import { clickOutsideAlerter, rpcEntriesToChainEntriesWithAllChainsEntry } from '../ui-utils.js' import { ChainEntry, RpcEntries, RpcEntry, RpcNetwork } from '../../types/rpc.js' -import { ReadonlySignal, Signal, useComputed } from '@preact/signals' +import { ReadonlySignal, Signal, useComputed, useSignal } from '@preact/signals' import { ChainIdWithUniversal } from '../../types/addressBookTypes.js' interface RpcSelectorParams { @@ -11,19 +11,19 @@ interface RpcSelectorParams { } export function RpcSelector(params: RpcSelectorParams) { - const [isOpen, setIsOpen] = useState(false) + const isOpen = useSignal(false) const wrapperRef = useRef(null) - clickOutsideAlerter(wrapperRef, () => setIsOpen(false)) + clickOutsideAlerter(wrapperRef, () => { isOpen.value = false }) function changeRpc(entry: RpcEntry) { params.changeRpc(entry) - setIsOpen(false) + isOpen.value = false } - return
+ return
@@ -46,20 +46,20 @@ interface ChainSelectorParams { } export function ChainSelector(params: ChainSelectorParams) { - const [isOpen, setIsOpen] = useState(false) + const isOpen = useSignal(false) const chains = useComputed(() => rpcEntriesToChainEntriesWithAllChainsEntry(params.rpcEntries.value)) const chain = useComputed(() => chains.value.find((chainEntry) => chainEntry.chainId === params.chainId.value)) const wrapperRef = useRef(null) - clickOutsideAlerter(wrapperRef, () => setIsOpen(false)) + clickOutsideAlerter(wrapperRef, () => { isOpen.value = false }) function changeChain(entry: ChainEntry) { params.changeChain(entry) - setIsOpen(false) + isOpen.value = false } - return
+ return