Skip to content

Commit

Permalink
Fix is selected noop (#3805)
Browse files Browse the repository at this point in the history
  • Loading branch information
abelsj60 authored Feb 2, 2023
1 parent 60704c7 commit b70fe79
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/lexical-react/src/useLexicalNodeSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,17 @@ export function useLexicalNodeSelection(
);

useEffect(() => {
return editor.registerUpdateListener(() => {
setIsSelected(isNodeSelected(editor, key));
let isMounted = true;
const unregister = editor.registerUpdateListener(() => {
if (isMounted) {
setIsSelected(isNodeSelected(editor, key));
}
});

return () => {
isMounted = false;
unregister();
};
}, [editor, key]);

const setSelected = useCallback(
Expand Down

2 comments on commit b70fe79

@vercel
Copy link

@vercel vercel bot commented on b70fe79 Feb 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

lexical – ./packages/lexical-website

lexicaljs.com
lexical.dev
lexical-fbopensource.vercel.app
lexical-git-main-fbopensource.vercel.app
lexicaljs.org
www.lexical.dev

@vercel
Copy link

@vercel vercel bot commented on b70fe79 Feb 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

lexical-playground – ./packages/lexical-playground

lexical-playground-fbopensource.vercel.app
lexical-playground-git-main-fbopensource.vercel.app
lexical-playground.vercel.app
playground.lexical.dev

Please sign in to comment.