Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance useLocalStorageState #146

Merged
merged 3 commits into from
Nov 17, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix typo
  • Loading branch information
awmleer committed Nov 13, 2019
commit 5bae27b75e770261f510432238e25539e14bc919
2 changes: 1 addition & 1 deletion src/useLocalStorageState/index_cn.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ const [state, setState] = useLocalStorageState<T>(
defaultValue?: T | (() => T),
): [T?, (value?: T) => void]
```
它的API和 `useState` 非常类似,但是多了一个参数 `key` ,用来指定在 localStorage 中存储时所使用的 `key` 。而它的返回值类型和 `useState` 保持来一致,当调用 `setState` 时,它会自动将新值写入到 localStorage 中。
它的API和 `useState` 非常类似,但是多了一个参数 `key` ,用来指定在 localStorage 中存储时所使用的 `key` 。而它的返回值类型和 `useState` 保持了一致,当调用 `setState` 时,它会自动将新值写入到 localStorage 中。

如果想从 localStorage 中删除这条数据,可以使用 `setState()` 或 `setState(undefined)` 。