Open History to see the last commit
1---
2id: PreactRateLimiter
3title: PreactRateLimiter
4---
5
6Defined in: [rate-limiter/useRateLimiter.ts:24](https://github.com/TanStack/pacer/blob/main/packages/preact-pacer/src/rate-limiter/useRateLimiter.ts#L24)
7
8## Extends
9
10- `Omit`\<`RateLimiter`\<`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: [rate-limiter/useRateLimiter.ts:50](https://github.com/TanStack/pacer/blob/main/packages/preact-pacer/src/rate-limiter/useRateLimiter.ts#L50)
32
33Reactive state that will be updated and re-rendered when the rate limiter state changes
34
35Use this instead of `rateLimiter.store.state`
36
37***
38
39### ~~store~~
40
41```ts
42readonly store: Store<Readonly<RateLimiterState>>;
43```
44
45Defined in: [rate-limiter/useRateLimiter.ts:56](https://github.com/TanStack/pacer/blob/main/packages/preact-pacer/src/rate-limiter/useRateLimiter.ts#L56)
46
47#### Deprecated
48
49Use `rateLimiter.state` instead of `rateLimiter.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: [rate-limiter/useRateLimiter.ts:41](https://github.com/TanStack/pacer/blob/main/packages/preact-pacer/src/rate-limiter/useRateLimiter.ts#L41)
62
63A Preact HOC (Higher Order Component) that allows you to subscribe to the rate limiter state.
64
65This is useful for opting into state re-renders for specific parts of the rate limiter 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<rateLimiter.Subscribe selector={(state) => ({ rejectionCount: state.rejectionCount })}>
94 {({ rejectionCount }) => (
95 <div>Rejections: {rejectionCount}</div>
96 )}
97</rateLimiter.Subscribe>
98```