Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> If you want to see really ugly code, read the docs about Higher Order Components

Never found HOC ugly, it's a normal function, not a magic one that hooks into React internals. Anyone familiar with OOP also regcognizes it as adapter. I think people tend to confuses syntactical simplicity with conceptual simplicity. But even syntactically, I don't find hooks simple once we pass the toy code examples.

> Hooks are better for building abstractions than HOCs

HOCs are more explicit, they change the props signature of the component. So if you like magic, you'd prefer hooks.

Hooks are not better abstraction, they are better building blocks because they compose more nicely.

A good abstraction is something you can pass around and use liberally without knowing the inner working. You can pass a HOC around and put it in conditional etc. Can't do that with hook because the inner working prohibits that and you are required to know such caveats.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: