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

fix(useStorageState): default value is not stored #2064

Merged
merged 6 commits into from Mar 7, 2023

Conversation

AmirabbasJ
Copy link
Contributor

@AmirabbasJ AmirabbasJ commented Feb 14, 2023

[中文版模板 / Chinese template]

🤔 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

💡 Background and solution

The issue was that the current implementation of useLocalStorageState does not save the default state to the storage (being localStorage on the web).

To fix that I just added a setDefaultStoredValue function which does that, and is only run when getStoredValue can't find any persisted data and resorts to the default value.

📝 Changelog

Language Changelog
🇺🇸 English fix(useStorageState): default value is not stored
🇨🇳 Chinese fix(useStorageStatej): 默认值没有被持久化

☑️ 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 14, 2023

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ liuyib
❌ AmirabbasJ
You have signed the CLA already but the status is still pending? Let us recheck it.

@liuyib
Copy link
Collaborator

liuyib commented Feb 20, 2023

CLA assistant check Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.You have signed the CLA already but the status is still pending? Let us recheck it.

@AmirabbasJ please sign the CLA

@liuyib liuyib self-requested a review March 6, 2023 12:13
@liuyib liuyib added this to In progress in ahooks tasks via automation Mar 6, 2023
@liuyib liuyib changed the title fix: store default value in useStorageState fix(useStorageState): default value is not stored Mar 6, 2023
@liuyib
Copy link
Collaborator

liuyib commented Mar 6, 2023

@crazylxr ready to merge

@crazylxr crazylxr merged commit 2042262 into alibaba:master Mar 7, 2023
ahooks tasks automation moved this from In progress to Done Mar 7, 2023
@liuyib liuyib mentioned this pull request Mar 14, 2023
18 tasks
liuyib added a commit that referenced this pull request Mar 20, 2023
@liuyib liuyib added the v4 label Mar 20, 2023
liuyib added a commit that referenced this pull request Mar 20, 2023
crazylxr pushed a commit that referenced this pull request Mar 21, 2023
…d "test(useStorageState): add test case (#2106)" (#2130)

* Revert "fix(useStorageState): default value is not stored (#2064)"

This reverts commit 2042262.

* Revert "test(useStorageState): add test case (#2106)"

This reverts commit 37749a3.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants