We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 39a5924 commit f63f14fCopy full SHA for f63f14f
.changeset/ripe-hands-remain.md
@@ -0,0 +1,5 @@
1
+---
2
+"kosha": patch
3
4
+
5
+fix: default to new value if not cached
lib/src/index.ts
@@ -55,7 +55,7 @@ export const create = <T extends BaseType>(storeCreator: StoreCreator<T>) => {
55
const useHook = <U = T>(selectorFunc?: (state: T) => U): U => {
56
const getSlice = () => {
57
const newValue = selectorFunc!(get()!);
58
- const obj = map.get(selectorFunc!);
+ const obj = map.get(selectorFunc!) ?? newValue;
59
const finalValue = JSON.stringify(obj) === JSON.stringify(newValue) ? obj : newValue;
60
map.set(selectorFunc!, finalValue);
61
return finalValue as U;
0 commit comments