From fcc26fec491b02566e52a2a99f101b868affe4a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Trzci=C5=84ski?= Date: Mon, 14 Oct 2024 18:14:32 +0200 Subject: [PATCH] [#65903] do not store components as state in YCommentsParent --- src/components/Comment.jsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/components/Comment.jsx b/src/components/Comment.jsx index 91bdc01..983831d 100644 --- a/src/components/Comment.jsx +++ b/src/components/Comment.jsx @@ -245,11 +245,8 @@ const PopupButton = ({ icon, onClick, text, bgOnHover }) => { /** @param {{ ycomments: YComments }} */ export const YCommentsParent = ({ ycomments, collaboration }) => { - let createWidget = ({ commentId }) => ; - let createWidgets = () => ycomments.iterComments().map(createWidget); - let [widgets, setWidgets] = useState(createWidgets()); + const [comments, setComments] = useState(ycomments.iterComments()); + useEffect(() => ycomments.display().onUpdate(() => setComments(ycomments.iterComments())), [ycomments]); - ycomments.display().onUpdate(() => setWidgets(createWidgets())); - - return <>{widgets}; + return comments.map(({ commentId }) => ); };