Skip to content

Commit 3182dbd

Browse files
committed
docs: add result
1 parent 397a0d5 commit 3182dbd

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

packages/hooks/src/useLocalStorageState/index.en-US.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,27 @@ A Hook that store state into localStorage.
2626
If you want to delete this record from localStorage, you can use `setState()` or `setState(undefined)`.
2727

2828
```typescript
29+
type SetState<S> = S | ((prevState?: S) => S);
2930
interface Options<T> {
3031
defaultValue?: T | (() => T);
3132
serializer?: (value: T) => string;
3233
deserializer?: (value: string) => T;
34+
onError?: (error: unknown) => void;
3335
}
3436

3537
const [state, setState] = useLocalStorageState<T>(
3638
key: string,
3739
options: Options<T>
38-
): [T?, (value?: T | ((previousState: T) => T)) => void];
40+
): [T?, (value?: SetState<T>) => void];
3941
```
4042
43+
### Result
44+
45+
| Property | Description | Type |
46+
| -------- | --------------------------- | ------------------------------- |
47+
| state | Local `localStorage` value | `T` |
48+
| setState | Update `localStorage` value | `(value?: SetState<T>) => void` |
49+
4150
### Options
4251
4352
| Property | Description | Type | Default |

packages/hooks/src/useLocalStorageState/index.zh-CN.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ nav:
2626
如果想从 localStorage 中删除这条数据,可以使用 `setState()``setState(undefined)`
2727

2828
```typescript
29+
type SetState<S> = S | ((prevState?: S) => S);
2930
interface Options<T> {
3031
defaultValue?: T | (() => T);
3132
serializer?: (value: T) => string;
@@ -35,9 +36,16 @@ interface Options<T> {
3536
const [state, setState] = useLocalStorageState<T>(
3637
key: string,
3738
options: Options<T>
38-
): [T?, (value?: T | ((previousState: T) => T)) => void];
39+
): [T?, (value?: SetState<T>) => void];
3940
```
4041
42+
### Result
43+
44+
| 参数 | 说明 | 类型 |
45+
| -------- | ---------------------- | ------------------------------- |
46+
| state | 本地 `localStorage` 值 | `T` |
47+
| setState | 设置 `localStorage` 值 | `(value?: SetState<T>) => void` |
48+
4149
### Options
4250
4351
| 参数 | 说明 | 类型 | 默认值 |

0 commit comments

Comments
 (0)