DEV Community

Discussion on: How to write 90% cleaner code with Hooks 🎣

Collapse
 
ctimmerman profile image
Cees Timmerman

Just when i thought React was the least horrible frontend framework, i read this. Why not a single VanillaJS file that registers an event listener to update its own properties?

Collapse
 
aman_singh profile image
Amandeep Singh • Edited

Hi Cees,

I may be wrong but are you talking about Event-driven-programming? Or I may have not understood your question properly here, but handling events and updating dom properties can be a cumbersome task. What React gives you is a declarative approach. It's more of like

 // UI is a function of data you pass
 data => UI

Moreover, React has its own implementation of a Data structure called Fiber which make sure to not block UI thread (main thread) and gives a performant UI. This is called the reconcilliation process.

I am pretty sure that handling UI updates via events only can be an assiduous task.

Thanks for your comment here 👏

Collapse
 
ctimmerman profile image
Cees Timmerman

Yes, for most programs a simple event handler that updates local properties should work fine.