From 0306280b2e520b1fc878663e486206176bdb7258 Mon Sep 17 00:00:00 2001 From: jinhojang6 Date: Wed, 30 Aug 2023 01:10:09 +0900 Subject: [PATCH] chore: use navigator.share for share button --- src/components/ShareButton/ShareButton.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/ShareButton/ShareButton.tsx b/src/components/ShareButton/ShareButton.tsx index 9dd12da..061153b 100644 --- a/src/components/ShareButton/ShareButton.tsx +++ b/src/components/ShareButton/ShareButton.tsx @@ -9,9 +9,10 @@ import { useClickAway } from 'react-use' type Props = { url: string + title?: string } -export default function ShareButton({ url }: Props) { +export default function ShareButton({ url, title }: Props) { const [showOptions, setShowOptions] = useState(false) const [copied, setCopied] = useState(false) const ref = useRef(null) @@ -20,8 +21,12 @@ export default function ShareButton({ url }: Props) { setShowOptions(false) }) - const handleCopyClipBoard = async (text: string) => { - await navigator.clipboard.writeText(text) + const handleCopyClipBoard = (url: string) => { + const shareObject = { + url: url, + } + + navigator.share(shareObject) setCopied(true) // TODO : Temporary solution