juststore 0.1.1 → 0.1.3
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/dist/root.js +3 -2
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/root.js
CHANGED
|
@@ -35,9 +35,10 @@ function createStoreRoot(namespace, defaultValue, options = {}) {
|
|
|
35
35
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
36
36
|
useSubscribe(joinPath(namespace, path), listener),
|
|
37
37
|
useCompute: (path, fn) => {
|
|
38
|
-
const
|
|
38
|
+
const fullPath = joinPath(namespace, path);
|
|
39
|
+
const initialValue = getSnapshot(fullPath);
|
|
39
40
|
const [computedValue, setComputedValue] = useState(() => fn(initialValue));
|
|
40
|
-
useSubscribe(
|
|
41
|
+
useSubscribe(fullPath, value => {
|
|
41
42
|
const newValue = fn(value);
|
|
42
43
|
if (!isEqual(computedValue, newValue)) {
|
|
43
44
|
setComputedValue(newValue);
|
package/dist/types.d.ts
CHANGED
|
@@ -102,7 +102,7 @@ type State<T> = {
|
|
|
102
102
|
children: React.ReactNode;
|
|
103
103
|
on: (value: T) => boolean;
|
|
104
104
|
}) => React.ReactNode;
|
|
105
|
-
};
|
|
105
|
+
} & (NonNullable<T> extends readonly (infer U)[] ? ArrayProxy<U> : unknown);
|
|
106
106
|
/** Props for Store.Render helper. */
|
|
107
107
|
type StoreRenderProps<T extends FieldValues, P extends FieldPath<T>> = {
|
|
108
108
|
path: P;
|