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

When the update method is called more frequently than requestAnimationFrame, NaN will be rendered #330

Open
tiger-with-wings opened this issue Jun 7, 2024 · 2 comments

Comments

@tiger-with-wings
Copy link

tiger-with-wings commented Jun 7, 2024

[ x ] Bug
[ ] Feature request

CountUp.js version: 2.8.0

Description

When the update method is called more frequently than requestAnimationFrame, NaN will be rendered:
image
image

@inorganik
Copy link
Owner

Your setInterval is updating the value at least every frame. If you want to update this way, increasing by 100 every ~10 milliseconds, do not use CountUp, because the setInterval will render the DOM about as often as requestAnimationFrame.

RequestAnimationFrame runs as often as your browser allows, usually between 30-60 FPS. setInterval used with a time value lower than the max FPS of your browser will effectively do the same.

As a side note, don't use ref.current in the dependency array of useEffect.

@tiger-with-wings
Copy link
Author

The above is just a reproduction problem.

The actual usage scenario is batch deletion. Each time the interface is called, 100 files can be deleted. After the deletion is successful, the interface is called again to delete the files. The front end accumulates and counts the number of files that have been successfully deleted. The interface response time is not fixed, so this problem still exists and occurs occasionally.

I hope to get support, thank you!

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

2 participants