The component renders the value the entry holds, or initial while the entry is empty. It stays in step with the
entry whoever changes it: the returned setter, or another page writing the entry, removing it or clearing the
storage area. Changes made by other pages arrive only for storage areas the browser shares across pages, in
practice localStorage.
The storage area and the key may change between renders. The component then renders and follows the new entry,
and the previous entry is left untouched.
Type Parameters
T
The type of the stored value
Parameters
storage: Storage
The storage area holding the entry, usually localStorage or sessionStorage
Binds a component to a value kept in Web Storage.
The component renders the value the entry holds, or
initialwhile the entry is empty. It stays in step with the entry whoever changes it: the returned setter, or another page writing the entry, removing it or clearing the storage area. Changes made by other pages arrive only for storage areas the browser shares across pages, in practicelocalStorage.The storage area and the key may change between renders. The component then renders and follows the new entry, and the previous entry is left untouched.