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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: useSessionStorageState throwing an exception with an error #2100

Closed
6 of 18 tasks
yulya9060 opened this issue Mar 7, 2023 · 2 comments 路 Fixed by #2123
Closed
6 of 18 tasks

feat: useSessionStorageState throwing an exception with an error #2100

yulya9060 opened this issue Mar 7, 2023 · 2 comments 路 Fixed by #2123
Assignees
Labels
enhancement Improvement or optimization

Comments

@yulya9060
Copy link

yulya9060 commented Mar 7, 2023

馃 This is a ...

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

馃敆 Related issue link

馃挕 Background and solution

  1. When adding a value to sessionStorage via the custom useStorageState hook, you may encounter the error "Failed to execute 'setItem' on 'Storage': Setting the value of 'storedFile' exceeded the quota". The hook has a method for adding a value to SS(setStoredValue), where it can be seen that in case of an error, in the catch block, the error is simply output to console.log. I would like to be able to catch this error to the developer.
  2. Screenshot 2023-03-07 at 09 42 10
  3. My suggestions: make it possible to set an errorCallback to which to pass an error, or throw an exception
    -->

馃摑 Changelog

Language Changelog
馃嚭馃嚫 English useStorageState catch SessionStorage error

鈽戯笍 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
@liuyib liuyib self-assigned this Mar 7, 2023
@liuyib liuyib added the enhancement Improvement or optimization label Mar 7, 2023
@liuyib
Copy link
Collaborator

liuyib commented Mar 7, 2023

@yulya9060 Can you give me some example code which you actually use, so that I can analyze this enhancement better, thx.

@liuyib
Copy link
Collaborator

liuyib commented Mar 20, 2023

Reproduce this step:

use a very large data to update local/sessionStorage. e.g.:

const [message, setMessage] = useSessionStorageState<string | undefined>('test-key');

setMessage(new Array(10000 * 100).fill('hello~').join(''));

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

Successfully merging a pull request may close this issue.

2 participants