useLocalstorageState
About
UseState but auto updates values to localStorage
Examples
Basic example
Using a boolean value to toggle a sidebar
Arguments
Argument value | Type | Description | Defualt |
---|---|---|---|
key | string | Key of the localStorage object | undefined |
defaultValue | any | Default initial value | null |
Returns
Returns an array of following items:
Return value | Type | Description |
---|---|---|
value | any | value stored in localStorage |
set | Function | set value stored in localStorage |
remove | Function | remove value stored in localStorage |