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

feat: add useIndexDBState hook #2740

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ianho
Copy link

@ianho ianho commented Feb 27, 2025

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

N/A

💡 Background and solution

IndexedDB 是浏览器提供的一种客户端存储方案,相比 localStorage 和 sessionStorage,它可以存储更大量的结构化数据。目前 ahooks 已经提供了 useLocalStorageState 和 useSessionStorageState,但还没有提供 IndexedDB 相关的 hook。

这个 PR 添加了 useIndexDBState hook,它可以将 React 状态持久化存储到 IndexedDB 中,并提供了类似于 useState 的 API,使用简单。

📝 Changelog

Language Changelog
🇺🇸 English Add useIndexDBState hook to persist state into IndexedDB.
🇨🇳 Chinese 添加 useIndexDBState hook,用于将状态持久化存储到 IndexedDB 中。

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@CLAassistant
Copy link

CLAassistant commented Feb 27, 2025

CLA assistant check
All committers have signed the CLA.

@ianho
Copy link
Author

ianho commented Feb 27, 2025

All by Cursor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants