3 ms·
Just chiming in to say that I too hope class components will continue to be supported. I worry that they'll announce otherwise in a couple years. Class compone
by oaxacaoaxaca 6y ago
Just chiming in to say that I too hope class components will continue to be supported. I worry that they'll announce otherwise in a couple years.
Class components are so stupidly simple to read and write. I appreciate the work put into function components, but to me they make things unnecessarily complex. Just the fact that they took callbacks and other functions from methods – where things are separate, clean, standard – to nested functions – where things are not separate (some local variables, some closure variables), not clean (no possible way to unit test a nested function in isolation), and not standard (object methods are a language feature, use them!) – seems like a huge step backward.
- nightski 6y agoYou 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.
- untog 6y agoYou can, yes. But the developer working on the codebase you’re going to inherit might not. Class components are usefully opinionated in that way.
- oaxacaoaxaca 6y agoYep. 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.
- nightski 6y agoAbsolutely there are cases where class components make sense. I highly doubt they would ever depreciate them.
- dmitryminkovsky 6y agoNot really lots of functions do have to be declared in useEffect for dependency management.
- nightski 6y agoI'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.