fix: Reduce ineffective triggering of the clipboard

This commit is contained in:
Ethan Liu 2023-06-21 12:20:49 +08:00
parent cfd367baf9
commit 25361c847b
3 changed files with 17 additions and 11 deletions

View file

@ -12,11 +12,11 @@ export function useCopyToClipboard({
const [isCopied, setIsCopied] = React.useState<Boolean>(false)
const copyToClipboard = (value: string) => {
if (
typeof window === 'undefined' ||
!navigator.clipboard ||
!navigator.clipboard.writeText
) {
if (typeof window === 'undefined' || !navigator.clipboard?.writeText) {
return
}
if (!value) {
return
}