|
|
|
|
|
by timhwang21
2016 days ago
|
|
One key difference between hooks and functions is that hooks tap into some hidden global component registry (I'm being handwavey here but this is more or less what happens). This allows side effects to be persisted and tracked between function calls. You can probably build all this infrastructure yourself without hooks and only with plain functions. It'll involve some global store and some subscription mechanism. You'll end up with something really similar to Redux. |
|
It sounds to me that such a concept would be very useful in a lot of contexts, so instead of specializing it only to react hooks, it might be better to just be a standalone library. E.g., why not use the same technique in Angular?
That way, developers don't have to learn framework-specific ways of doing things again and again but can reuse their knowledge. I think the fact that everyone is building their own thing is one of the reasons why many people have this notion of "need to learn a new framework every half a year". Backend technology seems to do better here, maybe because the pace is slower?