@t8/react-store 1.0.26 → 1.0.28

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 +23 -19
  3. package/package.json +5 -5
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Alexander Tkačenko
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
@@ -71,6 +71,8 @@ let [, setState] = useState(store, false);
71
71
  Apart from a boolean, `useStore(store, shouldUpdate)` accepts a function of `(nextState, prevState) => boolean` as the second parameter to filter store updates to respond to:
72
72
 
73
73
  ```jsx
74
+ import { useStore } from "@t8/react-store";
75
+
74
76
  let ItemCard = ({ id }) => {
75
77
  // Definition of changes in the item
76
78
  let hasRelevantUpdates = useCallback((nextItems, prevItems) => {
@@ -90,41 +92,43 @@ let ItemCard = ({ id }) => {
90
92
 
91
93
  Shared state can be provided to the app by means of a regular React Context provider:
92
94
 
93
- ```ts
94
- import { createContext } from "react";
95
+ ```diff
96
+ + import { createContext, useContext } from "react";
97
+ import { Store, useStore } from "@t8/react-store";
95
98
 
96
- export let AppContext = createContext(new Store(0));
97
- ```
99
+ - let counterStore = new Store(0);
100
+ + let AppContext = createContext(new Store(0));
98
101
 
99
- ```tsx
100
- let App = () => (
101
- <AppContext.Provider value={new Store(42)}>
102
- <PlusButton/>{" "}<Display/>
103
- </AppContext.Provider>
104
- );
105
- ```
102
+ let Counter = () => {
103
+ - let [counter, setCounter] = useStore(counterStore);
104
+ + let [counter, setCounter] = useStore(useContext(AppContext));
106
105
 
107
- ```tsx
108
- let Counter = () => {
109
- let [counter, setCounter] = useStore(useContext(AppContext));
106
+ // Rendering
107
+ };
110
108
 
111
- // Rendering
112
- };
109
+ let App = () => (
110
+ - <>
111
+ + <AppContext.Provider value={new Store(42)}>
112
+ <PlusButton/>{" "}<Display/>
113
+ + </AppContext.Provider>
114
+ - </>
115
+ );
113
116
  ```
114
117
 
115
118
  [Live counter demo with Context](https://codesandbox.io/p/sandbox/rtng37?file=%2Fsrc%2FPlusButton.jsx)
116
119
 
117
120
  🔹 In a multi-store setup, stores can be located in a single Context or split across multiple Contexts, just like any application data.
118
121
 
119
- ```js
122
+ ```jsx
123
+ import { createContext, useContext } from "react";
124
+ import { Store, useStore } from "@t8/react-store";
125
+
120
126
  // Multiple stores in a single Context
121
127
  let AppContext = createContext({
122
128
  users: new Store(/* ... */),
123
129
  items: new Store(/* ... */),
124
130
  });
125
- ```
126
131
 
127
- ```jsx
128
132
  let ItemCard = ({ id }) => {
129
133
  let [items, setItems] = useStore(useContext(AppContext).items);
130
134
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t8/react-store",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "description": "Concise shared state management for React apps",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -29,13 +29,13 @@
29
29
  "store"
30
30
  ],
31
31
  "author": "axtk",
32
- "license": "ISC",
32
+ "license": "MIT",
33
33
  "peerDependencies": {
34
34
  "react": ">=16.8"
35
35
  },
36
36
  "devDependencies": {
37
- "@playwright/test": "^1.55.1",
38
- "@t8/serve": "^0.1.29",
37
+ "@playwright/test": "^1.56.0",
38
+ "@t8/serve": "^0.1.30",
39
39
  "@types/node": "^24.5.2",
40
40
  "@types/react": "^19.1.10",
41
41
  "@types/react-dom": "^19.1.9",
@@ -44,6 +44,6 @@
44
44
  "typescript": "^5.9.3"
45
45
  },
46
46
  "dependencies": {
47
- "@t8/store": "^1.1.5"
47
+ "@t8/store": "^1.1.6"
48
48
  }
49
49
  }