DEV Community

Discussion on: Abstracting with react hooks on LSD

Collapse
 
mdovn profile image
mdovn

Hook is a double edge sword. Not only the abstraction cost but also performance. Only a small state in a hook changed and you will see that all the other hooks in the same component be re-evaluated as well. What if inside a hook inside a hook inside a hook... Which executes an expensive operation you were not aware of? Your users will feel the lagging and pitch off.
Don't get me wrong, nothing is perfect but it's too easy to do the bad thing with hook.

Collapse
 
patheticgeek profile image
Pathetic Geek

Well you can always write bad code so I guess the point should be that they are good but they should be used with care. Also i think the performance cost isn't that much and it might be the same as having those things inside the component. Can you refer to something where i can read more on the performance cost?

Collapse
 
mdovn profile image
mdovn

That's right, because human always (and will) make mistakes. The best we can do, in my opinion is try to design tools that make it hard to do stupid things.
You can read this article: dev.to/ryansolid/5-ways-solidjs-di...
I found the author has many good articles on the same topic which took a deep dive into reactivity of popular frontend libraries.
The above article is not exactly what I tend to share with you. I could not find the best one. I just remember it's also from same author

Thread Thread
 
patheticgeek profile image
Pathetic Geek

Yup i agree with that.
I wont perticularly switch to some other framework just because like I'm way too invested in this one and also like many companies have written stuff in these and those cant be changes as easily as i can switch frameowrk so i am more interested to just make existing stuff better and in only some cases creating new things.
I'll read the article you sent