title: How to get async/await function work with setTimeout
body: <p>I have an async function called getUser() which is used to query the API, I also have a search field in the UI (component coming from Semantic UI React) and it will query the API based on the data.searchQuery value, please see the code below:</p>
  <pre><code>&lt;&gt;
    &lt;Form.Dropdown
      search
      selection
      clearable
      fluid
      multiple
      width={width}
      name={name}
      placeholder=&quot;Start typing name to search&quot;
      onSearchChange={
        async (event, data) =&gt; {
          const query = data.searchQuery;
          const response = await getUser(query);
          
         // other code
    /&gt;
  &lt;/&gt;
  </code></pre>
  <p>Currently, if I input 'test' in the search field, it will query the API four times (with 't', 'te', 'tes', 'test'), <em><strong>what I would like to achieve is only call getUser() function if the user finishes typing (for example, if the user doesn't type anything in 1 second then start query the API).</strong></em> I found some example in the [documentation][1] of Semantic UI React (Please refer to the complete code snippet in the doc):</p>
  <pre><code> const timeoutRef = React.useRef()
  
  
  const handleSearchChange = React.useCallback((e, data) =&gt; {
      clearTimeout(timeoutRef.current)
      dispatch({ type: 'START_SEARCH', query: data.value })
  
      timeoutRef.current = setTimeout(() =&gt; {
         if (data.value.length === 0) {
            dispatch({ type: 'CLEAN_QUERY' })
            return
      }
  
      const re = new RegExp(_.escapeRegExp(data.value), 'i')
      const isMatch = (result) =&gt; re.test(result.title)
  
      dispatch({
         type: 'FINISH_SEARCH',
         results: _.filter(source, isMatch),
        })
      }, 3000)
  
    }, [])
  
    React.useEffect(() =&gt; {
      return () =&gt; {
        clearTimeout(timeoutRef.current)
      }
    }, [])
  </code></pre>
  <p>I tried to implement in the same way, but seems like I cannot do await inside setTimeout (await should only work with async function). How should I achieve this? Thank you!</p>