yuustate 3.10.0 → 3.10.1
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/esm/react/create-query.d.mts +1 -1
- package/esm/react/create-store.d.mts +1 -1
- package/esm/react/use-store.d.mts +1 -2
- package/esm/react.mjs +5 -6
- package/package.json +1 -1
- package/react/create-query.d.ts +1 -1
- package/react/create-store.d.ts +1 -1
- package/react/use-store.d.ts +1 -2
- package/react.js +5 -6
|
@@ -350,7 +350,7 @@ export declare const createQuery: <TData, TVariable extends StoreKey = never, TE
|
|
|
350
350
|
*/
|
|
351
351
|
initialDataIsStale?: boolean;
|
|
352
352
|
} | {
|
|
353
|
-
initialData?: never;
|
|
353
|
+
initialData?: never | undefined;
|
|
354
354
|
initialDataIsStale?: never;
|
|
355
355
|
})) => QueryState<TData, TError>) & {
|
|
356
356
|
setState: (value: SetStateInput<QueryState<TData, TError>>) => void;
|
|
@@ -31,5 +31,5 @@ export declare const createStore: <TState extends Record<string, any>>(initialSt
|
|
|
31
31
|
/**
|
|
32
32
|
* Initial state used on first render (and will also update the store state right after that)
|
|
33
33
|
*/
|
|
34
|
-
initialState?: Partial<TState
|
|
34
|
+
initialState?: Partial<TState> | undefined;
|
|
35
35
|
}) => TState) & import("../vanilla.d.mts").StoreApi<TState>;
|
|
@@ -4,7 +4,6 @@ export declare const getValueByPath: (obj: any, path: Path) => any;
|
|
|
4
4
|
export declare const isPrefixPath: (candidatePrefix: Path, targetPath: Path) => boolean;
|
|
5
5
|
export declare const compressPaths: (paths: Path[]) => Path[];
|
|
6
6
|
export declare const useStoreStateProxy: <TState extends Record<string, any>>(storeState: TState) => readonly [TState, import("react").RefObject<Path[]>];
|
|
7
|
-
export declare const NO_INITIAL_VALUE: {};
|
|
8
7
|
export declare const useStoreStateWithInitializer: <TState extends Record<string, any>>(store: StoreApi<TState>, initialState?: Partial<TState>) => readonly [TState, import("react").RefObject<WeakMap<StoreApi<TState>, number>>];
|
|
9
8
|
/**
|
|
10
9
|
* React hook for subscribing to a store using automatic dependency tracking.
|
|
@@ -29,6 +28,6 @@ export declare const useStoreStateWithInitializer: <TState extends Record<string
|
|
|
29
28
|
* // Component will only re-render if `user.name` changes
|
|
30
29
|
*/
|
|
31
30
|
export declare const useStoreState: <TState extends Record<string, any>>(store: StoreApi<TState>, options?: {
|
|
32
|
-
initialState?: Partial<TState
|
|
31
|
+
initialState?: Partial<TState> | undefined;
|
|
33
32
|
}) => TState;
|
|
34
33
|
export {};
|
package/esm/react.mjs
CHANGED
|
@@ -49,16 +49,15 @@ const useStoreStateProxy = (storeState) => {
|
|
|
49
49
|
}, [storeState]);
|
|
50
50
|
return [trackedState, usedPathsRef];
|
|
51
51
|
};
|
|
52
|
-
const
|
|
53
|
-
const useStoreStateWithInitializer = (store, initialState = NO_INITIAL_VALUE) => {
|
|
52
|
+
const useStoreStateWithInitializer = (store, initialState) => {
|
|
54
53
|
const initiatedAt = useRef(new WeakMap([[store, 0]]));
|
|
55
54
|
useEffect(() => {
|
|
56
|
-
if (initialState ===
|
|
55
|
+
if (initialState === void 0 || initiatedAt.current.get(store)) return;
|
|
57
56
|
store.setState(initialState);
|
|
58
57
|
initiatedAt.current.set(store, Date.now());
|
|
59
58
|
}, [store, initialState]);
|
|
60
59
|
const storeState = store.getState();
|
|
61
|
-
const finalState = initialState ===
|
|
60
|
+
const finalState = initialState === void 0 || initiatedAt.current.get(store) ? storeState : { ...storeState, ...initialState };
|
|
62
61
|
return [finalState, initiatedAt];
|
|
63
62
|
};
|
|
64
63
|
const useStoreState = (store, options = {}) => {
|
|
@@ -426,14 +425,14 @@ const createQuery = (queryFn, options = {}) => {
|
|
|
426
425
|
}
|
|
427
426
|
const useStore = (options2 = {}) => {
|
|
428
427
|
const {
|
|
429
|
-
initialData
|
|
428
|
+
initialData,
|
|
430
429
|
initialDataIsStale = false,
|
|
431
430
|
revalidateOnMount = true,
|
|
432
431
|
keepPreviousData
|
|
433
432
|
} = options2;
|
|
434
433
|
const [storeState, initialDataInitiatedAt] = useStoreStateWithInitializer(
|
|
435
434
|
store,
|
|
436
|
-
initialData ===
|
|
435
|
+
initialData === void 0 ? void 0 : {
|
|
437
436
|
state: "SUCCESS",
|
|
438
437
|
isSuccess: true,
|
|
439
438
|
data: initialData
|
package/package.json
CHANGED
package/react/create-query.d.ts
CHANGED
|
@@ -350,7 +350,7 @@ export declare const createQuery: <TData, TVariable extends StoreKey = never, TE
|
|
|
350
350
|
*/
|
|
351
351
|
initialDataIsStale?: boolean;
|
|
352
352
|
} | {
|
|
353
|
-
initialData?: never;
|
|
353
|
+
initialData?: never | undefined;
|
|
354
354
|
initialDataIsStale?: never;
|
|
355
355
|
})) => QueryState<TData, TError>) & {
|
|
356
356
|
setState: (value: SetStateInput<QueryState<TData, TError>>) => void;
|
package/react/create-store.d.ts
CHANGED
|
@@ -31,5 +31,5 @@ export declare const createStore: <TState extends Record<string, any>>(initialSt
|
|
|
31
31
|
/**
|
|
32
32
|
* Initial state used on first render (and will also update the store state right after that)
|
|
33
33
|
*/
|
|
34
|
-
initialState?: Partial<TState
|
|
34
|
+
initialState?: Partial<TState> | undefined;
|
|
35
35
|
}) => TState) & import("../vanilla.ts").StoreApi<TState>;
|
package/react/use-store.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ export declare const getValueByPath: (obj: any, path: Path) => any;
|
|
|
4
4
|
export declare const isPrefixPath: (candidatePrefix: Path, targetPath: Path) => boolean;
|
|
5
5
|
export declare const compressPaths: (paths: Path[]) => Path[];
|
|
6
6
|
export declare const useStoreStateProxy: <TState extends Record<string, any>>(storeState: TState) => readonly [TState, import("react").RefObject<Path[]>];
|
|
7
|
-
export declare const NO_INITIAL_VALUE: {};
|
|
8
7
|
export declare const useStoreStateWithInitializer: <TState extends Record<string, any>>(store: StoreApi<TState>, initialState?: Partial<TState>) => readonly [TState, import("react").RefObject<WeakMap<StoreApi<TState>, number>>];
|
|
9
8
|
/**
|
|
10
9
|
* React hook for subscribing to a store using automatic dependency tracking.
|
|
@@ -29,6 +28,6 @@ export declare const useStoreStateWithInitializer: <TState extends Record<string
|
|
|
29
28
|
* // Component will only re-render if `user.name` changes
|
|
30
29
|
*/
|
|
31
30
|
export declare const useStoreState: <TState extends Record<string, any>>(store: StoreApi<TState>, options?: {
|
|
32
|
-
initialState?: Partial<TState
|
|
31
|
+
initialState?: Partial<TState> | undefined;
|
|
33
32
|
}) => TState;
|
|
34
33
|
export {};
|
package/react.js
CHANGED
|
@@ -51,16 +51,15 @@ const useStoreStateProxy = (storeState) => {
|
|
|
51
51
|
}, [storeState]);
|
|
52
52
|
return [trackedState, usedPathsRef];
|
|
53
53
|
};
|
|
54
|
-
const
|
|
55
|
-
const useStoreStateWithInitializer = (store, initialState = NO_INITIAL_VALUE) => {
|
|
54
|
+
const useStoreStateWithInitializer = (store, initialState) => {
|
|
56
55
|
const initiatedAt = react.useRef(new WeakMap([[store, 0]]));
|
|
57
56
|
react.useEffect(() => {
|
|
58
|
-
if (initialState ===
|
|
57
|
+
if (initialState === void 0 || initiatedAt.current.get(store)) return;
|
|
59
58
|
store.setState(initialState);
|
|
60
59
|
initiatedAt.current.set(store, Date.now());
|
|
61
60
|
}, [store, initialState]);
|
|
62
61
|
const storeState = store.getState();
|
|
63
|
-
const finalState = initialState ===
|
|
62
|
+
const finalState = initialState === void 0 || initiatedAt.current.get(store) ? storeState : { ...storeState, ...initialState };
|
|
64
63
|
return [finalState, initiatedAt];
|
|
65
64
|
};
|
|
66
65
|
const useStoreState = (store, options = {}) => {
|
|
@@ -428,14 +427,14 @@ const createQuery = (queryFn, options = {}) => {
|
|
|
428
427
|
}
|
|
429
428
|
const useStore = (options2 = {}) => {
|
|
430
429
|
const {
|
|
431
|
-
initialData
|
|
430
|
+
initialData,
|
|
432
431
|
initialDataIsStale = false,
|
|
433
432
|
revalidateOnMount = true,
|
|
434
433
|
keepPreviousData
|
|
435
434
|
} = options2;
|
|
436
435
|
const [storeState, initialDataInitiatedAt] = useStoreStateWithInitializer(
|
|
437
436
|
store,
|
|
438
|
-
initialData ===
|
|
437
|
+
initialData === void 0 ? void 0 : {
|
|
439
438
|
state: "SUCCESS",
|
|
440
439
|
isSuccess: true,
|
|
441
440
|
data: initialData
|