zustand-querystring 0.0.2 → 0.0.4
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 +5 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/middleware.d.ts +1 -1
- package/lib/middleware.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
A zustand middleware that stores state in the querystring.
|
|
4
4
|
|
|
5
|
+
Try on [StackBlitz](https://stackblitz.com/github/nitedani/zustand-querystring/tree/main/examples/react) (You need to click "Open in New Tab")
|
|
6
|
+
|
|
5
7
|
Quickstart:
|
|
6
8
|
```ts
|
|
7
9
|
import create from "zustand";
|
|
8
10
|
import { immer } from "zustand/middleware/immer";
|
|
9
|
-
import {
|
|
11
|
+
import { querystring } from "zustand-querystring";
|
|
10
12
|
|
|
11
13
|
interface Store {
|
|
12
14
|
count: number;
|
|
@@ -25,7 +27,7 @@ interface Store {
|
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
export const useStore = create<Store>()(
|
|
28
|
-
|
|
30
|
+
querystring(
|
|
29
31
|
immer((set, get) => ({
|
|
30
32
|
count: 0,
|
|
31
33
|
incrementCount: () =>
|
|
@@ -59,7 +61,7 @@ export const useStore = create<Store>()(
|
|
|
59
61
|
select(pathname) {
|
|
60
62
|
return {
|
|
61
63
|
count: true,
|
|
62
|
-
// ticks: false, <- false by default
|
|
64
|
+
// ticks: false, <- false by default
|
|
63
65
|
|
|
64
66
|
someNestedState: {
|
|
65
67
|
nestedCount: true,
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { querystring, QueryStringOptions } from './middleware.js';
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { querystring } from './middleware.js';
|
package/lib/middleware.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export interface QueryStringOptions<T> {
|
|
|
7
7
|
select?: (pathname: string) => DeepSelect<T>;
|
|
8
8
|
}
|
|
9
9
|
type QueryString = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, Mps, Mcs>, options?: QueryStringOptions<T>) => StateCreator<T, Mps, Mcs>;
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const querystring: QueryString;
|
|
11
11
|
export {};
|
package/lib/middleware.js
CHANGED