4 ms·
If you happen to use React, I built a React component that helps you manage this! :) Hopefully it helps a bit! It also reports whether or not a user is idle, su
by skilgarriff 10y ago
If you happen to use React, I built a React component that helps you manage this! :) Hopefully it helps a bit! It also reports whether or not a user is idle, such that you can reduce cpu usage during that as well.
https://github.com/Skilgarriff/react-user-focus https://github.com/Skilgarriff/react-user-focus
- LeanderK 10y agoi don't know anything about React, but why can't react itself try to manage this?
- STRML 10y agoReact is in the business of limiting its API surface, not increasing it. I think they have done a great job of it - libraries like this should exist in userland.
- cpeterso 10y agoIt seems like React could listen for visibilitychange itself to throttle its own events or virtual DOM processing. It wouldn't necessarily need to expose visibilitychange as a library API.
- KirinDave 10y agoBecause there is no sufficient magic for that. App developers have to think about when they do work, how much work they do, and if and when it should be rendered. For any rule you can give, I can give you an example of an app that would break. In general, the mantra for people who find this tough to fix should be, "Why didn't I use MVC, what a cretin I was!"