Open History to see the last commit
1---
2id: PreactBatcher
3title: PreactBatcher
4---
5
6Defined in: [batcher/useBatcher.ts:20](https://github.com/TanStack/pacer/blob/main/packages/preact-pacer/src/batcher/useBatcher.ts#L20)
7
8## Extends
9
10- `Omit`\<`Batcher`\<`TValue`\>, `"store"`\>
11
12## Type Parameters
13
14### TValue
15
16`TValue`
17
18### TSelected
19
20`TSelected` = \{
21\}
22
23## Properties
24
25### state
26
27```ts
28readonly state: Readonly<TSelected>;
29```
30
31Defined in: [batcher/useBatcher.ts:46](https://github.com/TanStack/pacer/blob/main/packages/preact-pacer/src/batcher/useBatcher.ts#L46)
32
33Reactive state that will be updated and re-rendered when the batcher state changes
34
35Use this instead of `batcher.store.state`
36
37***
38
39### ~~store~~
40
41```ts
42readonly store: Store<Readonly<BatcherState<TValue>>>;
43```
44
45Defined in: [batcher/useBatcher.ts:52](https://github.com/TanStack/pacer/blob/main/packages/preact-pacer/src/batcher/useBatcher.ts#L52)
46
47#### Deprecated
48
49Use `batcher.state` instead of `batcher.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) => ComponentChildren;
59```
60
61Defined in: [batcher/useBatcher.ts:37](https://github.com/TanStack/pacer/blob/main/packages/preact-pacer/src/batcher/useBatcher.ts#L37)
62
63A Preact HOC (Higher Order Component) that allows you to subscribe to the batcher state.
64
65This is useful for opting into state re-renders for specific parts of the batcher 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`ComponentChildren` \| ((`state`) => `ComponentChildren`)
81
82###### selector
83
84(`state`) => `TSelected`
85
86#### Returns
87
88`ComponentChildren`
89
90#### Example
91
92```ts
93<batcher.Subscribe selector={(state) => ({ size: state.size })}>
94 {({ size }) => (
95 <div>Batch Size: {size}</div>
96 )}
97</batcher.Subscribe>
98```