"use client"; import { useLayoutEffect, useMemo, type ReactNode } from "react"; import { useCommentStore } from "../react/CommentProvider"; type CommentDetailPageProps = { id: string; basePath?: string; renderRestoredView: (props: { route: string }) => ReactNode; renderNotFound?: (props: { basePath: string }) => ReactNode; }; export function CommentDetailPage({ id, basePath = "/canvas", renderRestoredView, renderNotFound, }: CommentDetailPageProps) { const { annotations, restoreComment } = useCommentStore(); const annotation = useMemo( () => annotations.find((item) => item.id === id), [annotations, id] ); useLayoutEffect(() => { if (annotation) { restoreComment(annotation.id); } }, [annotation, restoreComment]); if (!annotation) { if (renderNotFound) { return <>{renderNotFound({ basePath })}; } return (

No comment exists with this id.

Back to canvas
); } return <>{renderRestoredView({ route: annotation.interactionState.route })}; }