Hacker News new | ask | show | jobs
by MiddleMan5 1564 days ago
Slightly dismissive, but I agree the setInterval function was a little misleadingly contrived.

The transition to functional components was to reduce the coupling between abstract functionality and DOM-related lifecycle events.

React hooks are mostly about expressing where and when you want to memoize a value, with the default being not to.

Once you learn what to look out for, and properly designing and review codebases at scale, these trivial issues don't happen all that often. Additionally, being able to specify memoization parameters explicitly brings extra flexibility and some additional design patterns.

1 comments

What are you talking about? The setInterval example is completely idiomatic React hooks. It is literally given in the React docs:

https://reactjs.org/docs/hooks-faq.html#what-can-i-do-if-my-...

Reading it now, the language I used was inappropriate. You're correct, the stated problem is common with registering and triggering self-repeating and timed loops.

That was really my point, don't do that.