index.tsx300 chars13 lines
This function first reads the clipboard data synchronously and then sets the value to a local storage key. Once the clipboard data has been read, it sets the value to local storage by calling the setItem()
function on the localStorage
object, using the storageKey
as the key and the clipboardData
as the value.
Note that the navigator.clipboard.readText()
function returns a promise, so we need to use the then()
method to wait for the promise to resolve before setting the local storage value.
gistlibby LogSnag