From 160ac53ee7e2318eae5adcf0914e192f5113c464 Mon Sep 17 00:00:00 2001 From: Sudhanshu Tiwary <146623832+sudhanshutiwary69868@users.noreply.github.com> Date: Thu, 24 Oct 2024 12:17:20 +0530 Subject: [PATCH] Update SignupForm.jsx Added a debouncing logic so as to handle multiple requests --- client/modules/User/components/SignupForm.jsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/client/modules/User/components/SignupForm.jsx b/client/modules/User/components/SignupForm.jsx index 75ab6910e..531baed48 100644 --- a/client/modules/User/components/SignupForm.jsx +++ b/client/modules/User/components/SignupForm.jsx @@ -24,10 +24,17 @@ function asyncValidate(fieldToValidate, value) { return ''; }); } - +let timeout=0 function validateUsername(username) { - return asyncValidate('username', username); -} + clearTimeout(timeout) + let timeout= setTimeout(function(){ + //added debouncing + //if someone starts typing in the frontend it will take 100ms to call backend + //it will eventually help for multiple requests at same time + //deferring the backend request + asyncValidate('username', username) + },100 + } function validateEmail(email) { return asyncValidate('email', email);