Features | useListenOnAnimationFrame |
setInterval |
requestAnimationFrame |
other animation frame libraries |
---|---|---|---|---|
suitable for frequent DOM mutations | yes | no | yes | commonly yes |
single animation frame loop | yes, for whole application | not applicable | not by default | no, common to have multiple frame loops |
performant & consistent | yes | no | depends on implementation | depends on implementation |
side effects | yes and yes | no | no | no, commonly not |
extensively controllable (start/stop & side effects) | yes and yes and yes, and even for side effects with multiple options [1] [2] | no | no | no, commonly not |
autoclean (start/stop/unmount) | yes, it even automatically stops and starts request animation frame loop only when needed | no | no | commonly not fully, it keeps animation frame loop even when not needed |
configurable | yes! [1] [2] [3] | no | no | commonly not |
accessing previous return value | yes, even for side effects | no | no | commonly not |