Open History to see the last commit
1---
2id: ReactDebouncer
3title: ReactDebouncer
4---
5
6Defined in: [debouncer/useDebouncer.ts:24](https://github.com/TanStack/pacer/blob/main/packages/react-pacer/src/debouncer/useDebouncer.ts#L24)
7
8## Extends
9
10- `Omit`\<`Debouncer`\<`TFn`\>, `"store"`\>
11
12## Type Parameters
13
14### TFn
15
16`TFn` *extends* `AnyFunction`
17
18### TSelected
19
20`TSelected` = \{
21\}
22
23## Properties
24
25### state
26
27```ts
28readonly state: Readonly<TSelected>;
29```
30
31Defined in: [debouncer/useDebouncer.ts:50](https://github.com/TanStack/pacer/blob/main/packages/react-pacer/src/debouncer/useDebouncer.ts#L50)
32
33Reactive state that will be updated and re-rendered when the debouncer state changes
34
35Use this instead of `debouncer.store.state`
36
37***
38
39### ~~store~~
40
41```ts
42readonly store: Store<Readonly<DebouncerState<TFn>>>;
43```
44
45Defined in: [debouncer/useDebouncer.ts:56](https://github.com/TanStack/pacer/blob/main/packages/react-pacer/src/debouncer/useDebouncer.ts#L56)
46
47#### Deprecated
48
49Use `debouncer.state` instead of `debouncer.store.state` if you want to read reactive state.
50The state on the store object is not reactive, as it has not been wrapped in a `useSelector` hook internally.
51Although, you can make the state reactive by using the `useSelector` in your own usage.
52
53***
54
55### Subscribe
56
57```ts
58Subscribe: <TSelected>(props) => ReactNode | Promise<ReactNode>;
59```
60
61Defined in: [debouncer/useDebouncer.ts:41](https://github.com/TanStack/pacer/blob/main/packages/react-pacer/src/debouncer/useDebouncer.ts#L41)
62
63A React HOC (Higher Order Component) that allows you to subscribe to the debouncer state.
64
65This is useful for opting into state re-renders for specific parts of the debouncer state
66deep in your component tree without needing to pass a selector to the hook.
67
68#### Type Parameters
69
70##### TSelected
71
72`TSelected`
73
74#### Parameters
75
76##### props
77
78###### children
79
80`ReactNode` \| ((`state`) => `ReactNode`)
81
82###### selector
83
84(`state`) => `TSelected`
85
86#### Returns
87
88`ReactNode` \| `Promise`\<`ReactNode`\>
89
90#### Example
91
92```ts
93<debouncer.Subscribe selector={(state) => ({ isPending: state.isPending })}>
94 {({ isPending }) => (
95 <div>{isPending ? 'Loading...' : 'Ready'}</div>
96 )}
97</debouncer.Subscribe>
98```