Skip to content
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] Slow unmount with many usages / larger component tree #339

Open
hejtmii opened this issue Apr 13, 2022 · 1 comment
Open

[BUG] Slow unmount with many usages / larger component tree #339

hejtmii opened this issue Apr 13, 2022 · 1 comment

Comments

@hejtmii
Copy link

hejtmii commented Apr 13, 2022

Describe the bug
When HotKeys component gets unmounted, it internally calls this line of code

this.logger.verbose(this.logger.nonKeyEventPrefix(componentId), 'De-registered component. Remaining component Registry:\n', "".concat(printComponent(this.componentTree.toJSON())));

Even that .verbose is noop, the serialization of the component tree is non-trivial with larger component tree and many instances of HotKeys are consuming a lot of browser resources.

Here is a screenshot from the profiler spammed with printComponent calls

image

How are you using react hotkeys components? (HotKeys, GlobalHotKeys, IgnoreKeys etc)
We use HotKeys and GlobalHotkeys on multiple components, some of them are very large (e.g. rich text editor)

Expected behavior
I would expect more lazy logging, not calling such costly operations when the logging is disabled

Platform (please complete the following information):

  • react-hotkeys 2.0.3 (but same code is in 2.0.4)
  • Chrome
  • Windows

Are you willing and able to create a PR request to fix this issue?
I could, but I would first like to discuss some best practice how to do that

@hejtmii
Copy link
Author

hejtmii commented Apr 14, 2022

Here is a PR that fixes the issue
ibash#8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant