fix: clipboard.writeText run with async
This commit is contained in:
@@ -5,9 +5,9 @@ import { useState } from "react";
|
|||||||
|
|
||||||
export default function CopyBtn({ text }) {
|
export default function CopyBtn({ text }) {
|
||||||
const [copied, setCopied] = useState(false);
|
const [copied, setCopied] = useState(false);
|
||||||
const handleClick = (e) => {
|
const handleClick = async (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
navigator.clipboard.writeText(text);
|
await navigator.clipboard.writeText(text);
|
||||||
setCopied(true);
|
setCopied(true);
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
|
|||||||
Reference in New Issue
Block a user