8000 Option for not persisting in local storage? · Issue #87 · tasoskakour/react-use-oauth2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Option for not persisting in local storage? #87

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

Open
woigl opened this issue Sep 23, 2023 · 1 comment
Open

Option for not persisting in local storage? #87

woigl opened this issue Sep 23, 2023 · 1 comment

Comments

@woigl
Copy link
Contributor
woigl commented Sep 23, 2023

First of all, let me express my gratitude for this library.

I propose a feature to deactivate persisting in the local storage by not calling the respective setData(...). The reason is that I don't need the data persistent as I handle all the rest on the backend. You may have a better idea to achieve this in compliance with your vision of this library.

Would it be okay if I prepare the code and initiate a pull request, or you don't want this enhancement?

Thanks in advance for your consideration.

@tasoskakour tasoskakour changed the title Option for not persisting in session storage? Option for not persisting in local storage? Sep 24, 2023
@tasoskakour
Copy link
Owner

Hey @woigl

That wouldn't be a bad idea actually. Although not something urgent, it would be maybe a "nice-to-have" 🙂

I believe though, that if we go with this approach it would be more beneficial to write our own hook for persisting the state and not relying on the use-local-storage-state hook that we currently rely on.

It could be something like:

const [state, setState] =  usePersistedState(
   storageKey,
   defaultState, 
   { persist: true | false, storage: window.localStorage | window.sessionStorage }
);
  • With persist: false a user could skip the persistence whatsoever.
  • With storage: window.sessionStorage a user could persist to sessionStorage instead of localStorage

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

No branches or pull requests

2 participants
0