context-scoped-state 0.0.4 → 0.0.5
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 +4 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,13 +62,13 @@ export const useCounterStore = createStoreHook(CounterStore);
|
|
|
62
62
|
import { useCounterStore } from './stores/counterStore';
|
|
63
63
|
|
|
64
64
|
function Counter() {
|
|
65
|
-
const
|
|
65
|
+
const counterStore = useCounterStore();
|
|
66
66
|
|
|
67
67
|
return (
|
|
68
68
|
<div>
|
|
69
|
-
<span>{
|
|
70
|
-
<button onClick={() =>
|
|
71
|
-
<button onClick={() =>
|
|
69
|
+
<span>{counterStore.state.count}</span>
|
|
70
|
+
<button onClick={() => counterStore.increment()}>+</button>
|
|
71
|
+
<button onClick={() => counterStore.decrement()}>-</button>
|
|
72
72
|
</div>
|
|
73
73
|
);
|
|
74
74
|
}
|
|
@@ -179,7 +179,6 @@ No mocking libraries. No global state cleanup. Just render with the state you ne
|
|
|
179
179
|
- Building reusable components with internal state
|
|
180
180
|
- You want test isolation without extra setup
|
|
181
181
|
- State naturally belongs to a subtree, not the whole app
|
|
182
|
-
- You prefer OOP patterns (classes, methods)
|
|
183
182
|
|
|
184
183
|
**Need global state?** Just place the Context at your app root — same API, app-wide access.
|
|
185
184
|
|