import { useCallback } from 'react'; interface IShareProps { title?: string, text?: string, url: 'https://developer.mozilla.org', } /** * Hook para api de compartilhamento nativo. * @returns {{ * handleShare: (data: {}) => Promise; * }} */ export const useShare = (): { handleShare: (data: IShareProps) => Promise; } => { const handleShare = useCallback(async (data) => { try { await navigator.share(data); } catch (err) { throw new Error(`Erro ao compartilhar. ${err}`); } }, []); return { handleShare }; };