Re:Making SetInterval Declarative with React Hooks
by panic on Monday February 04, 2019 @02:17AM
(#19074537)
Resetting the interval when the delay changes is probably not what you want either -- quickly changing the delay (even a little bit) won't give the timer a chance to fire. It would be better to compute a deadline internally, then move the deadline forward or backward according to how much the delay changed since the last call.
[ Parent
| on HN ]
Re:Making SetInterval Declarative with React Hooks
by danabramov on Monday February 04, 2019 @06:21AM
(#19075431)
Good thing something like useInterval() can abstract these implementation details away so it can be made more precise with time. :-)