Skip to content

Commit

Permalink
⚡️(frontend) remove debounce on useHeadings
Browse files Browse the repository at this point in the history
We remove the debounce on useHeadings, it
decreases the user experience and it's not
necessary a big performance improvement.
  • Loading branch information
AntoLC committed Dec 11, 2024
1 parent a902e31 commit a8310fa
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ export const useHeadings = (editor: BlockNoteEditor) => {
useEffect(() => {
setHeadings(editor);

let timeout: NodeJS.Timeout;
editor?.onEditorContentChange(() => {
clearTimeout(timeout);
timeout = setTimeout(() => setHeadings(editor), 200);
setHeadings(editor);
});

return () => {
clearTimeout(timeout);
resetHeadings();
};
}, [editor, resetHeadings, setHeadings]);
Expand Down

0 comments on commit a8310fa

Please sign in to comment.