Framework
Version
防抖器 API 參考
節流器 API 參考
速率限制器 API 參考
佇列 API 參考

Solid 適配器

若您正在 Solid 應用程式中使用 TanStack Pacer,我們推薦使用 Solid 轉接器 (Solid Adapter)。此轉接器在核心 Pacer 工具之上提供了一系列易用的鉤子 (hooks)。如果您想直接使用核心 Pacer 的類別/函式,Solid 轉接器也會重新匯出核心套件的所有內容。

安裝

sh
npm install @tanstack/solid-pacer
npm install @tanstack/solid-pacer

Solid 鉤子 (Hooks)

請參閱 Solid 函式參考文件 以查看 Solid 轉接器中提供的完整鉤子清單。

基本用法

從 Solid 轉接器匯入專為 Solid 設計的鉤子:

tsx
import { useDebouncedValue } from '@tanstack/solid-pacer'

const [instantValue, instantValueRef] = useState(0)
const [debouncedValue, debouncer] = useDebouncedValue(instantValue, {
  wait: 1000,
})
import { useDebouncedValue } from '@tanstack/solid-pacer'

const [instantValue, instantValueRef] = useState(0)
const [debouncedValue, debouncer] = useDebouncedValue(instantValue, {
  wait: 1000,
})

或是匯入由 Solid 轉接器重新匯出的核心 Pacer 類別/函式:

tsx
import { debounce, Debouncer } from '@tanstack/solid-pacer' // 無需另行安裝核心套件
import { debounce, Debouncer } from '@tanstack/solid-pacer' // 無需另行安裝核心套件
Subscribe to Bytes

Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.

Bytes

No spam. Unsubscribe at any time.