|
|
|
|
|
by codeflo
1551 days ago
|
|
I’ll prefix by saying I agree with a lot of the criticisms, and I’ve experienced first hand how hard to explain and error prone hooks are. But for this post, let me defend the concept. The idea, in a very rough nutshell, is to allow separating behavior and presentation. Hooks are the reusable unit of behavior. You compose hooks into more complex hooks that might implement loading and saving data from/to the server, for example. Then you can use this hook with different components, or use the same component in a different context with a different data source. This can be very powerful if used well. But as I said at the beginning, hooks are unfortunately also very difficult to get right. |
|