4 ms·
I dont get hooks. How is this simpler than something like this? https://jsfiddle.net/xv7y9eoz/ https://jsfiddle.net/xv7y9eoz/
by thecatspaw 8y ago
I dont get hooks. How is this simpler than something like this?
https://jsfiddle.net/xv7y9eoz/ https://jsfiddle.net/xv7y9eoz/
- wawhal 8y agoI don't buy the way things are done in this library (constate). I wouldn't import a library just for doing this. It is not very hard to achieve the same with plain `useContext` and `useState` directly. That being said, I don't agree that hooks are futile, because, using hooks, your state logic can be reused. For example, if your app uses 10 independent counters (with different render logic and different styling), hooks are definitely useful to reuse the state logic.
- esamatti 8y agoThat only uses local state. With constate you can access the state from anywhere without prop drilling.
- antihero 8y agoJust because the example people use (incrementing a counter) is simple and can be solved very simply, it doesn't mean that these simple solutions will work well for more complex issues. Of course most people are not building apps that just increment a counter. Hooks are for much more than that.