-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: DecoratorNode
's component does not call useEffect
cleanup until after remount
#2993
Comments
Ah, I think I might know why this is happening. We are capturing the We should probably move this line down to where we actually use it. Feel free to put up a PR if you'd like to contribute to Lexical :) thanks for finding the issue too! |
Not sure where your React 18 comment went but I tested with React 18 in the repro and same issue. Will have a look at LexicalUpdates code and see if I can make sense of it :) |
I had hard time a few days ago with the decorator node deletion. At some point, in my app, some decorator nodes were deleted whereas it should not be deleted, It was then rendered again. I don't have bandwith for now to setup a reproducer, but though useful to mention that. That behavior can be reproduced in the playground if you console.log in the cleanup function fo a useEffect. And yes, I have seen that pendingDecorators was in the picture (the first deleted decorator node was removed, then the cleanup functions were called on the second decorator node delettion, with potentially other non deleted nodes by the user being deleted and directly re-rendered (which in my case was giving issues to the state I was maintaining in the decorator nodes). |
I believe the changes I mentioned above should help in both your cases. I’m on parental leave right now and on my phone otherwise I’d put up a PR. |
DecoratorNode.decorate
can return JSX element to render React components. Surprisingly, when you delete aDecoratorNode
,useEffect
cleanup functions are not called. Even more surprisingly, when you undo the delete, theuseEffect
cleanup function is called.Lexical version: 0.4.1
Steps To Reproduce
The current behavior
Cleanup doesn't happen when DecoratorNode is delete. It happens if and when the DecoratorNode is remounted.
The expected behavior
Cleanup should happen at the expected point in the component lifecycle, i.e. when it unmounts / when it looks like it unmounts.
The text was updated successfully, but these errors were encountered: