Skip to content

Commit

Permalink
fix: unsubscribe ydoc update listener
Browse files Browse the repository at this point in the history
  • Loading branch information
lawvs committed Apr 11, 2024
1 parent ebc8518 commit 7e1ec0d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/preview-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ export function PreviewPanel() {
if (!yDoc) {
return;
}
yDoc.on("update", () => {
const callback = () => {
// Force re-render
setCount((count) => count + 1);
});
};
yDoc.on("update", callback);
return () => {
yDoc.off("update", callback);
};
}, [yDoc]);

return (
Expand Down

0 comments on commit 7e1ec0d

Please sign in to comment.