3 Minutes With Kent
Avoid Hasty Abstractions: Hooks edition
- Autor: Vários
- Narrador: Vários
- Editora: Podcast
- Duração: 0:02:59
- Mais informações
Informações:
Sinopse
Hello friends, so I wanted to talk today about whether or not you should make a custom hook for everything. So a few days ago, maybe last week there was this thing going around where people were recommending that you never ever use the react built-in hooks inside of a component, you always extract it to a custom hook. This is terrible advice. Don't do that at all. So the way that I think about hooks in React is the they're basically functions that have the,Only special distinction of being functions that actually call other hooks. That's the only thing special about them. So everything else about this function is the same as regular functions. And you don't make a function for every line of code that you write right? Like that would be ridiculous. The reason that we make functions is to encapsulate certain logic. And most of the time it's useful mostly for reuse. Sometimes it could be nice to take a bunch of chunks of code. And logically put it together so that it can be separate from the rest of our our code