diff --git a/src/components/Hero.jsx b/src/components/Hero.jsx index d19ba1d..8510ea4 100644 --- a/src/components/Hero.jsx +++ b/src/components/Hero.jsx @@ -20,6 +20,7 @@ import Loading from '../img/loading.svg'; export function Hero(props) { const contractAddress = props.contractAddress; const { isConnected, address } = useAccount(); + const [throttled, setThrottled] = useState(''); const [tokensMinted, setTokensMinted] = useState(() => { const saved = localStorage.getItem('tokensMinted-v3-' + address); @@ -58,6 +59,14 @@ export function Hero(props) { function handleStateChange(obj) { setOptions(preState => ({...preState , ...obj})); } + function throttleStateChange(obj) { + const og = throttled; + let t = setTimeout(function() { + setOptions(preState => ({...preState , ...obj})); + }, 600); + setThrottled(t); + clearTimeout(og); + } const defOpt = { address: contractAddress, abi: MainABI, @@ -283,7 +292,7 @@ export function Hero(props) { && ( <> { - handleStateChange({unaboomerAmount: v.target.value}); + throttleStateChange({unaboomerAmount: v.target.value}); radicalizeBoomersWrite.reset() }}>