hooks icon indicating copy to clipboard operation
hooks copied to clipboard

feat: add useIndexDBState hook

Open ianho opened this issue 10 months ago • 2 comments

🤔 This is a ...

  • [x] 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. ⚠️

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

ianho avatar Feb 27 '25 09:02 ianho

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Feb 27 '25 09:02 CLAassistant

All by Cursor

ianho avatar Feb 27 '25 09:02 ianho