context-scoped-state 0.0.2 → 0.0.4

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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -14
  3. package/package.json +5 -2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Harsh Rohila
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -32,10 +32,11 @@ pnpm add context-scoped-state
32
32
 
33
33
  ## Quick Start
34
34
 
35
- ### 1. Define Your Store
35
+ ### 1. Create Your Store (one file, one export)
36
36
 
37
37
  ```tsx
38
- import { Store } from 'context-scoped-state';
38
+ // stores/counterStore.ts
39
+ import { Store, createStoreHook } from 'context-scoped-state';
39
40
 
40
41
  class CounterStore extends Store<{ count: number }> {
41
42
  protected getInitialState() {
@@ -50,19 +51,16 @@ class CounterStore extends Store<{ count: number }> {
50
51
  this.setState({ count: this.getState().count - 1 });
51
52
  }
52
53
  }
53
- ```
54
-
55
- ### 2. Create the Hook
56
54
 
57
- ```tsx
58
- import { createStoreHook } from 'context-scoped-state';
59
-
60
- const useCounterStore = createStoreHook(CounterStore);
55
+ // This single export is all you need
56
+ export const useCounterStore = createStoreHook(CounterStore);
61
57
  ```
62
58
 
63
- ### 3. Use in Components
59
+ ### 2. Use in Your App
64
60
 
65
61
  ```tsx
62
+ import { useCounterStore } from './stores/counterStore';
63
+
66
64
  function Counter() {
67
65
  const store = useCounterStore();
68
66
 
@@ -75,7 +73,6 @@ function Counter() {
75
73
  );
76
74
  }
77
75
 
78
- // Wrap with Context provider
79
76
  function App() {
80
77
  return (
81
78
  <useCounterStore.Context>
@@ -85,7 +82,7 @@ function App() {
85
82
  }
86
83
  ```
87
84
 
88
- That's it. No providers at the root, no selectors, no reducers, no actions, no dispatch.
85
+ That's it. One hook export gives you the hook and its `.Context` provider. No extra setup needed.
89
86
 
90
87
  ## Examples
91
88
 
@@ -190,8 +187,8 @@ No mocking libraries. No global state cleanup. Just render with the state you ne
190
187
 
191
188
  **vs useState:**
192
189
 
193
- - `useState` binds state logic directly to the component, making it hard to reuse or test independently
194
- - With `context-scoped-state`, state logic lives in a separate class — reusable across components and easily testable
190
+ - `useState` binds state directly to the component poor separation of concerns and hard to test since you can't easily set a component to a specific state
191
+ - Lifting state up with `useState` requires refactoring components and passing props; with `context-scoped-state`, just move the Context wrapper up the tree
195
192
 
196
193
  **vs useReducer:**
197
194
 
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "context-scoped-state",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
+ "license": "MIT",
4
5
  "type": "module",
5
6
  "repository": {
6
7
  "type": "git",
7
- "url": "https://github.com/HarshRohila/context-scoped-state.git"
8
+ "url": "https://github.com/HarshRohila/context-scoped-state.git",
9
+ "directory": "packages/context-store-react"
8
10
  },
9
11
  "keywords": [
10
12
  "react",
@@ -30,6 +32,7 @@
30
32
  },
31
33
  "files": [
32
34
  "dist",
35
+ "LICENSE",
33
36
  "!**/*.tsbuildinfo"
34
37
  ],
35
38
  "peerDependencies": {