You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/framework/react/adapter.md
+170Lines changed: 170 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,3 +34,173 @@ Or import a core Pacer class/function that is re-exported from the React Adapter
34
34
import { debounce, Debouncer } from'@tanstack/react-pacer'// no need to install the core package separately
35
35
```
36
36
37
+
## Option Helpers
38
+
39
+
If you want a type-safe way to define common options for pacer utilities, TanStack Pacer provides option helpers for each utility. These helpers can be used with React hooks.
The React Adapter provides a `PacerProvider` component that you can use to provide default options to all instances of pacer utilities within your component tree.
Don't have TanStack Pacer installed yet? See the [Installation](../installation.md) page for instructions.
12
9
13
-
If you're looking lower-level examples or `async` examples, take a look at our catalog of examples.
10
+
## Understanding Which Pacer Utility to Use
11
+
12
+
Still learning what TanStack Pacer is and how it can help your application? See the [Which Pacer Utility Should I Choose?](../guides/which-pacer-utility-should-i-choose.md) guide for help choosing which Pacer utility to use. The TanStack Pacer libraries have 5 core utilities, but also quite a few flexible ways to use each utility. Famarilizing yourself with the above guide will help you choose the right utility for your use case.
13
+
14
+
## API References
15
+
16
+
See the [API References](../reference/index.md) page for the full list of API references for each Pacer utility.
17
+
18
+
## Basic Usage
19
+
20
+
If you are using vanilla JavaScript, there are core classes and functions that you can use from the core pacer package.
21
+
22
+
### Class Usage
23
+
24
+
```ts
25
+
import { Debouncer } from'@tanstack/pacer'// class
26
+
27
+
const debouncer =newDebouncer(fn, options)
28
+
29
+
debouncer.maybeExecute(args) // execute the debounced function
30
+
debouncer.cancel() // cancel the debounced function
31
+
debouncer.flush() // flush the debounced function
32
+
```
33
+
34
+
### Function Usage
35
+
36
+
```ts
37
+
import { debounce } from'@tanstack/pacer'// function
38
+
39
+
const debouncedFn =debounce(fn, options)
40
+
41
+
debouncedFn(args) // execute the debounced function
42
+
```
43
+
44
+
### Framework Hook Usage (Recommended)
45
+
46
+
If you are using a framework adapter like React, you can use the `useDebouncer` hook to create a debounced function.
TanStack Pacer provides an official TanStack Devtools integration for each framework adapter. See the [Devtools](../devtools.md) documentation for more information on how to set up and use the Pacer devtools.
0 commit comments