@octanejs/zustand 0.1.50 → 0.1.52
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 +3 -10
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -57,8 +57,9 @@ hook used twice) stay independent, exactly like in React.
|
|
|
57
57
|
## Selecting object slices — `useShallow`
|
|
58
58
|
|
|
59
59
|
A selector that returns a fresh object/array each call (`(s) => ({ a: s.a })`) never
|
|
60
|
-
compares Object.is-equal, so it
|
|
61
|
-
`useShallow` to
|
|
60
|
+
compares Object.is-equal, so it violates `useSyncExternalStore` snapshot stability
|
|
61
|
+
and reaches the maximum update depth guard. Wrap it with `useShallow` to cache
|
|
62
|
+
the selection by shallow equality:
|
|
62
63
|
|
|
63
64
|
```tsx
|
|
64
65
|
import { useShallow } from '@octanejs/zustand/shallow';
|
|
@@ -69,14 +70,6 @@ function Sliced() @{
|
|
|
69
70
|
}
|
|
70
71
|
```
|
|
71
72
|
|
|
72
|
-
## Divergences from React
|
|
73
|
-
|
|
74
|
-
- **Unstable selectors don't loop.** React's `useSyncExternalStore` throws the dev
|
|
75
|
-
warning _"The result of getSnapshot should be cached"_ and re-renders in a loop when
|
|
76
|
-
a selector returns a new reference every render. octane settles after a bounded
|
|
77
|
-
number of renders instead — no loop, no warning. Prefer `useShallow` regardless, for
|
|
78
|
-
the same reason you would in React (avoid the extra renders).
|
|
79
|
-
|
|
80
73
|
## Equality functions — `traditional`
|
|
81
74
|
|
|
82
75
|
For the equality-fn pattern, `@octanejs/zustand/traditional` provides
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octanejs/zustand",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.52",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -45,15 +45,15 @@
|
|
|
45
45
|
"zustand": "^5.0.14"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"octane": "0.1.51"
|
|
48
|
+
"octane": "^0.1.51 || ^0.2.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@tsrx/react": "^0.2.
|
|
51
|
+
"@tsrx/react": "^0.2.67",
|
|
52
52
|
"esbuild": "^0.28.1",
|
|
53
|
-
"react": "
|
|
54
|
-
"react-dom": "
|
|
53
|
+
"react": "19.2.7",
|
|
54
|
+
"react-dom": "19.2.7",
|
|
55
55
|
"vitest": "^4.1.10",
|
|
56
|
-
"octane": "0.
|
|
56
|
+
"octane": "0.2.5"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"test": "vitest run"
|