Hacker News new | ask | show | jobs
by nightski 2142 days ago
You can create isolated functions instead of nested functions wherever you want. Just pass in params instead of using closures. This is entirely up to the developer.
2 comments

You can, yes. But the developer working on the codebase you’re going to inherit might not. Class components are usefully opinionated in that way.
Yep. And isolated functions are a solution, but sometimes it just makes way more sense for that function to be a method of a class. And for the function component to be a class component. I think there's space for both types of components, and I just hope that class components don't become deprecated.
Absolutely there are cases where class components make sense. I highly doubt they would ever depreciate them.
Not really lots of functions do have to be declared in useEffect for dependency management.
I'm not aware of any case in which this is true. Effects are run on every render unless you explicitly specify dependencies in the second argument of the hook.