How to use the ahooks.useDebounce function in ahooks

To help you get started, we’ve selected a few ahooks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pingcap / tidb-dashboard / ui / lib / apps / Configuration / index.tsx View on Github external
export default function () {
  const {
    data,
    isLoading,
    error,
    sendRequest,
  } = useClientRequest((reqConfig) =>
    client.getInstance().configurationGetAll(reqConfig)
  )

  const { t } = useTranslation()
  const [filterValueLower, setFilterValueLower] = useState('')
  const debouncedFilterValue = useDebounce(filterValueLower, { wait: 200 })

  const handleSaved = useCallback(() => {
    sendRequest()
  }, [sendRequest])

  const handleFilterChange = useCallback((e) => {
    setFilterValueLower(e.target.value.toLowerCase())
  }, [])

  const errors = useMemo(() => {
    if (error) {
      return [error]
    }
    if (data?.errors) {
      return data.errors
    }