Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SignupForm.jsx #3256

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions client/modules/User/components/SignupForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't want a let here because that will create a separate timeout variable that is scoped to within the body of the validateUsername function, rather than re-using the one that you declared outside the function body.

//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);
Expand Down