Skip to content
Discussion options

You must be logged in to vote

i found a solution. I am using the invoke function inside my handleAsyncInput function like this:

const handleAsyncInput = useDebouncedCallback(async (value: string) => {
  if (value !== "") {
    setLoading(true)
    try {
      const usernameAvailable = await invoke(getUsername, { username: value })
      if (usernameAvailable) {
        setUsernameAvailable(true)
      } else {
        helper.setError("Username already taken. Please choose another")
      }
    } catch (error) {
      console.log(error)
    }
    setLoading(false)
  }
}, 300)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by niklasgrewe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant