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
The returned hook supports both selector and auto-tracked modes, plus custom `isEqual` — identical to `useClassyStore`, but with the store already bound:
`createStoreHook` validates its argument immediately — if you pass something that isn't a store proxy, it throws at module load time rather than on first render.
Copy file name to clipboardExpand all lines: website/docs/index.md
+50Lines changed: 50 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -181,6 +181,56 @@ The factory runs once per mount. Subsequent re-renders reuse the same store inst
181
181
182
182
> See the [Local Stores](./TUTORIAL.md#local-stores) section in the Tutorial for persistence patterns and more examples.
183
183
184
+
### `createStoreHook(store)`
185
+
186
+
Creates a pre-bound React hook for a specific store proxy. Eliminates the boilerplate of writing a typed wrapper around `useClassyStore` for every store instance.
Copy file name to clipboardExpand all lines: website/static/llms-full.txt
+61-1Lines changed: 61 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -189,9 +189,39 @@ function Counter() {
189
189
190
190
The factory runs once per mount. Subsequent re-renders reuse the same store instance.
191
191
192
+
### `createStoreHook(store)`
193
+
194
+
Creates a pre-bound React hook for a specific store proxy. Eliminates the boilerplate of writing a typed wrapper around `useClassyStore` for every store instance.
195
+
196
+
```ts
197
+
import {createClassyStore} from '@codebelt/classy-store';
198
+
import {createStoreHook} from '@codebelt/classy-store/react';
The returned hook supports both selector and auto-tracked modes, plus custom `isEqual` — identical to `useClassyStore`, but with the store already bound:
`createStoreHook` validates its argument immediately — if you pass something that isn't a store proxy, it throws at module load time rather than on first render.
0 commit comments