diff --git a/src/app/r/[slug]/not-found.tsx b/src/app/r/[slug]/not-found.tsx index df8c471..5fca86a 100644 --- a/src/app/r/[slug]/not-found.tsx +++ b/src/app/r/[slug]/not-found.tsx @@ -9,7 +9,7 @@ export default function NotFound() { Link Not Found

- The link you're looking for doesn't exist or has expired. + The link you're looking for doesn't exist or has expired.

({}) const router = useRouter() - function handleCopy(string: string) { + const handleCopy = React.useCallback((string: string) => { navigator.clipboard.writeText(string).then(() => { toast.success("URL copied to clipboard") }).catch(() => { toast.error("Failed to copy URL") }) - } + }, []) - async function handleDelete(id: string) { + const handleDelete = React.useCallback(async (id: string) => { const res = await deleteUrl(id) if (res.error) { @@ -255,49 +255,51 @@ export function UrlsDataTable({ data }: UrlsDataTableProps) { toast.success("URL deleted successfully") router.refresh() } - } + }, [router]) - const actionRow: ColumnDef = { - id: "actions", - enableHiding: false, - cell: ({ row }) => { - const urlRecord = row.original + const tableColumns = React.useMemo(() => { + const actionRow: ColumnDef = { + id: "actions", + enableHiding: false, + cell: ({ row }) => { + const urlRecord = row.original - return ( - - - - - - Actions - { - handleCopy(`${window.location.origin}/r/${urlRecord.slug}`) - }} - > - - Copy URL - - - { - handleDelete(urlRecord.id) - }} - > - - Delete - - - - ) + return ( + + + + + + Actions + { + handleCopy(`${window.location.origin}/r/${urlRecord.slug}`) + }} + > + + Copy URL + + + { + handleDelete(urlRecord.id) + }} + > + + Delete + + + + ) + } } - } - const tableColumns = React.useMemo(() => [...columns, actionRow], [actionRow]) + return [...columns, actionRow] + }, [handleCopy, handleDelete]) const table = useReactTable({ data,