@t8/react-store 1.0.15 → 1.0.17
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 +6 -3
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -46,7 +46,8 @@ Moving the local state to the full-fledged shared state:
|
|
|
46
46
|
let App = () => <><Counter/>{" "}<ResetButton/></>;
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
[Live demo](https://codesandbox.io/p/sandbox/rtng37?file=%2Fsrc%2FPlusButton.jsx)
|
|
49
|
+
[Live counter demo](https://codesandbox.io/p/sandbox/rtng37?file=%2Fsrc%2FPlusButton.jsx)<br>
|
|
50
|
+
[Tic-tac-toe](https://codesandbox.io/p/sandbox/tq852v?file=%252Fsrc%252FApp.tsx)
|
|
50
51
|
|
|
51
52
|
🔹 The shared state setup with `@t8/react-store` is very similar to `useState()` allowing for quick migration from local state to shared state or the other way around.
|
|
52
53
|
|
|
@@ -65,7 +66,9 @@ let AppContext = createContext({
|
|
|
65
66
|
|
|
66
67
|
```jsx
|
|
67
68
|
let ItemCard = ({ id }) => {
|
|
69
|
+
// Definition of changes in the item
|
|
68
70
|
let hasRelevantUpdates = useCallback((nextItems, prevItems) => {
|
|
71
|
+
// Assuming that items have a `revision` property
|
|
69
72
|
return nextItems[id].revision !== prevItems[id].revision;
|
|
70
73
|
}, [id]);
|
|
71
74
|
|
|
@@ -75,7 +78,7 @@ let ItemCard = ({ id }) => {
|
|
|
75
78
|
);
|
|
76
79
|
|
|
77
80
|
return (
|
|
78
|
-
//
|
|
81
|
+
// Content
|
|
79
82
|
);
|
|
80
83
|
};
|
|
81
84
|
```
|
|
@@ -105,4 +108,4 @@ Live demos:<br>
|
|
|
105
108
|
|
|
106
109
|
---
|
|
107
110
|
|
|
108
|
-
- [
|
|
111
|
+
- [T8 React Pending](https://github.com/t8js/react-pending) for shared async action state tracking
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t8/react-store",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "Straightforward and minimalist shared state management for React apps",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"preversion": "npx npm-run-all typecheck shape build test",
|
|
15
15
|
"shape": "npx codeshape",
|
|
16
16
|
"test": "npx playwright test --project=chromium",
|
|
17
|
+
"tic-tac-toe": "npx @t8/serve 3000 * tests/tic-tac-toe -b src/index.tsx",
|
|
17
18
|
"typecheck": "tsc --noEmit"
|
|
18
19
|
},
|
|
19
20
|
"repository": {
|