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

Hooks: add useStorage hook #2773

Closed
melloware opened this issue Apr 20, 2022 · 0 comments · Fixed by #2774
Closed

Hooks: add useStorage hook #2773

melloware opened this issue Apr 20, 2022 · 0 comments · Fixed by #2774
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@melloware
Copy link
Member

I'm submitting a ... (check one with "x")

 [x] feature request

Expected behavior
need a re-usable hook that can be a drop in replacement for useState that can store either in session or local storage. For example..

Use State:

const [theme, setTheme] = useState('lara-light-indigo');

Would be able to be switched to browser localStorage with 1 line drop in change where you give it the key where you want it to be stored.

Local Storage:

const [theme, setTheme] = useStorage('lara-light-indigo', 'primereact-theme`, 'local');

SessionsStorage:

const [theme, setTheme] = useStorage('lara-light-indigo', 'primereact-theme`, 'session');
@melloware melloware added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Apr 20, 2022
@melloware melloware added this to the 8.0.0.Final milestone Apr 20, 2022
@melloware melloware self-assigned this Apr 20, 2022
melloware added a commit to melloware/primereact that referenced this issue Apr 20, 2022
mertsincan pushed a commit that referenced this issue Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant