File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' zustand-x ' : minor
3+ ---
4+
5+ - Introduced a React-free ` createVanillaStore ` in ` zustand-x/vanilla ` using ` zustand/vanilla ` .
6+ - Extracted shared internal logic (` middleware ` , ` options parsing ` , ` selector/action helpers ` ) to ` src/internal ` for reuse.
7+ - Refactored React entry (` createStore ` , hooks) to use shared internal logic without breaking existing API.
8+ - Split types: base hook-free definitions vs React-specific types for compatibility with both entries.
9+ - Updated package exports to include ` ./vanilla ` while keeping ` . ` for React.
10+ - Added vanilla-focused tests to ensure store functionality works without React.
11+ - Ensured middleware, selector/action extensions, and mutative utilities work in both vanilla and React contexts.
12+ - ** Example usage (vanilla, no React):**
13+
14+ ``` ts
15+ import { createVanillaStore } from ' zustand-x/vanilla' ;
16+
17+ const counterStore = createVanillaStore (
18+ { count: 0 },
19+ { name: ' vanilla-counter' , persist: true }
20+ )
21+ .extendSelectors (({ get }) => ({
22+ doubled : () => get (' count' ) * 2 ,
23+ }))
24+ .extendActions (({ set }) => ({
25+ increment : () => set (' count' , (value ) => value + 1 ),
26+ }));
27+
28+ counterStore .actions .increment ();
29+ console .log (counterStore .get (' doubled' )); // 2
30+ ```
You can’t perform that action at this time.
0 commit comments