context-scoped-state 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="logo.svg" alt="context-scoped-state logo" width="120" height="120">
|
|
3
|
+
<h1>context-scoped-state</h1>
|
|
4
|
+
<p><strong>State management that respects component boundaries.</strong></p>
|
|
5
|
+
</div>
|
|
4
6
|
|
|
5
7
|
Unlike global state libraries (Redux, Zustand), `context-scoped-state` keeps your state where it belongs — scoped to the component tree that needs it. Each context provider creates an independent store instance, making your components truly reusable and your tests truly isolated.
|
|
6
8
|
|
|
@@ -30,12 +32,16 @@ pnpm add context-scoped-state
|
|
|
30
32
|
|
|
31
33
|
> **Peer Dependencies:** React 18+
|
|
32
34
|
|
|
35
|
+
## Try it Online
|
|
36
|
+
|
|
37
|
+
[](https://stackblitz.com/github/HarshRohila/context-scoped-state/tree/master/examples/playground)
|
|
38
|
+
|
|
33
39
|
## Quick Start
|
|
34
40
|
|
|
35
41
|
### 1. Create Your Store (one file, one export)
|
|
36
42
|
|
|
37
43
|
```tsx
|
|
38
|
-
//
|
|
44
|
+
// counterStore.ts
|
|
39
45
|
import { Store, createStoreHook } from 'context-scoped-state';
|
|
40
46
|
|
|
41
47
|
class CounterStore extends Store<{ count: number }> {
|
|
@@ -59,7 +65,7 @@ export const useCounterStore = createStoreHook(CounterStore);
|
|
|
59
65
|
### 2. Use in Your App
|
|
60
66
|
|
|
61
67
|
```tsx
|
|
62
|
-
import { useCounterStore } from './
|
|
68
|
+
import { useCounterStore } from './counterStore';
|
|
63
69
|
|
|
64
70
|
function Counter() {
|
|
65
71
|
const counterStore = useCounterStore();
|