vituarvom / react-smart-utils

A simple, smart hooks and utility functions to make development easier
https://www.npmjs.com/package/react-smart-utils
13 stars 34 forks source link

Implement useLocalStorage hook #14

Open bharat-dussa opened 1 month ago

bharat-dussa commented 1 month ago

A hook for interacting with localStorage, allowing you to get and set values while persisting them in the browser's local storage.

Parameters:

key: string – The key to access in localStorage.
initialValue: any – The initial value to set if no value exists.

Returns:

value: any – The current value in localStorage.
setValue: (value: any) => void – A function to update the value in localStorage.
const [value, setValue] = useLocalStorage('theme', 'dark');

Goal: Create a hook that syncs state with localStorage, making it easy to store and retrieve persistent data.

ReenaChidrala commented 1 month ago

pls assing this issue I won't to contribute @bharat-dussa