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

improve performance by adding enabled flag to useWatcher #196

Merged
merged 1 commit into from
Nov 6, 2020

Conversation

tzimmermann
Copy link
Contributor

  • we only need to register the measuring callback if we actually have a node prop.
  • this reduced a lot of unnecessary computations that made applications with a lot of Stick components slow over time.

Here are two performance measurements, using no node prop.
This is the status quo: a lot of CPU usage and calculations going on, even there are no interactions with the page and no node needs to be measured:

react-stick-enabled-usewatch

After our opmizations: almost no CPU usage any more in the idle state:
react-stick-disabled-usewatch

@vercel
Copy link

vercel bot commented Nov 6, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/signavio/react-stick/2xio9lb4u
✅ Preview: https://react-stick-git-fix-usewatcher-performance.signavio.now.sh

- we only need to register the measuring callback if we actually have a `node` prop.
- this reduced a lot of unnecessary computations that made applications with a lot of `Stick` components slow over time.

Co-authored-by: Andreas Köberle <koeberle@gmail.com>
Copy link
Contributor

@frontendphil frontendphil left a comment

Choose a reason for hiding this comment

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

Nice one! Thank you 👍

@frontendphil frontendphil merged commit a063a26 into master Nov 6, 2020
@frontendphil frontendphil deleted the fix/useWatcher-performance branch November 6, 2020 12:48
@workflow-bot
Copy link

🎉 This PR is included in version 4.1.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

3 participants