From 7f2dcaf1474b29b9425b355793060648b23a174f Mon Sep 17 00:00:00 2001 From: lza_menace Date: Wed, 28 Dec 2022 02:44:03 -0800 Subject: [PATCH] setting up debounce --- src/template/Sections.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/template/Sections.jsx b/src/template/Sections.jsx index d990d20..fff83ec 100644 --- a/src/template/Sections.jsx +++ b/src/template/Sections.jsx @@ -20,7 +20,14 @@ import '../styles/sections.css'; const contractAddress = '0x5FbDB2315678afecb367f032d93F642f64180aa3'; - +function debounce(callback, wait) { + let timeout; + return (...args) => { + const context = this; + clearTimeout(timeout); + timeout = setTimeout(() => callback.apply(context, args), wait); + }; +} export class Section1 extends React.Component { constructor(props) { @@ -103,6 +110,7 @@ export function Section3() { } ], watch: true, + cacheTime: 4_000, onSuccess(data) { setBoomerPrice(data[0].toString()); setBombPrice(data[1].toString()); @@ -151,7 +159,7 @@ export function Section3() { setBoomerAmount(v)} /> + }} onChange={v => debounce(setBoomerAmount(v), 500)} />

Assemble Bombs