import { useCallback, useState } from "react"; import { useFetchNativeCurrencyPrice } from "@scaffold-ui/hooks"; import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork"; type TBalanceProps = { value?: string; className?: string; }; /** * Display (ETH & USD) value for the input value provided. */ export const ETHToPrice = ({ value, className = "" }: TBalanceProps) => { const [isEthBalance, setIsEthBalance] = useState(true); const { targetNetwork } = useTargetNetwork(); const { price } = useFetchNativeCurrencyPrice(); const onToggleBalance = useCallback(() => { if (price > 0) { setIsEthBalance(!isEthBalance); } }, [isEthBalance, price]); if (!value) { return (
); } return ( ); };