chore: use navigator.share for share button

This commit is contained in:
jinhojang6 2023-08-30 01:10:09 +09:00
parent 5301bd2fe8
commit 0306280b2e
1 changed files with 8 additions and 3 deletions

View File

@ -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