Skip to content

Commit 9389b32

Browse files
committed
changeset
1 parent 49a50e5 commit 9389b32

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

.changeset/pink-guests-jump.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
```

0 commit comments

Comments
 (0)