Better HN
topnewbestaskshowjobs
Log inSign up

contigo

2 karma · joined Apr 27, 2020 (6y ago) · 1 submissions

Submissions

comment 6y ago · link · parent

IMAO hooks are just a dirty hack, but sold very well. Internally in React the state of a hook is being kept and updated when you call the set function, kinda similar to vtables and context in OOP. There is no other way to do this AFAIK. It only mimics functional programming, and that's why you see the restrictions about hooks, you cannot use them outside React, cannot nest, etc..