Files
my-website-v2/frontend/components/ShareLinkButton.tsx

14 lines
364 B
TypeScript
Raw Normal View History

2025-07-17 21:23:16 -04:00
export const ShareLinkButton = function ShareLinkButton({ props }) {
const [text, setText] = useState("Share");
2025-06-29 23:41:20 -04:00
const onClickHandler = () => {
navigator.clipboard.writeText(location.href);
setText("Copied to clipboard!");
2025-07-17 21:23:16 -04:00
setTimeout(() => {
setText("Share");
}, 1000);
2025-06-29 23:41:20 -04:00
};
2025-07-17 21:23:16 -04:00
return <button onClick={onClickHandler}>{text}</button>;
};