useStorage
If we want to persist data, we can choose between two storages:
- The session storage(new tab)which stores data only for the active session
- The local storage(new tab)which stores data until it is actively cleared
To use those in a convenient way, Flora provides a hook for each storage.
They share the same signature.
Do's & Don'ts
Use the session storage for sensitive data such as contact information and bank details.
Params
Name | Type | Default | Description |
|---|---|---|---|
defaultValue* | any | A default value with which the storage is initially populated | |
key* | string | The that is used to reference the stored value |
Returns
Array: An array containing the value, a setter and reset function:Note: The first two values act exactly the same as React's
useState