Hacker News new | past | comments | ask | show | jobs | submit login

Can you qualify this? My experience has been the exact opposite. Angular rewrote their entire framework to be more one-way data-binding focused because the two-way in AngularJS was a nightmare. They still have a weird mechanism to allow it, and they still have lots of wiring all over the place.

Modern React, with hooks and functional components, solves the problem posed in the article by choosing option 2, lift the state up. The hypothetical problem (change the avatar background when the “working” light is on) is a non-issue. You wouldn’t add an event listener for the light’s state change, you’d simply pass the “isWorking” prop to both the light and the avatar, and they would each render based on the value of “isWorking”. There is no reason for one component to know about the other; they don’t actually do anything except sit there and look pretty, correctly.

The UI is always backed by a data model. The more explicitly you express that model—by keeping it all in one tree like Redux does, for instance—the simpler your UI becomes to reason about. React won’t (can’t) stop you from doing bad things like hitting random services when a component loads, but its design, especially recently, guides you away from that pitfall.




Regular binding in Angular is straight forward: you can pass params to child component and you can bind to events. Child does not know about parent by design. So it is a good practice baked in Angular.

If it comes to the question. I think you have answered yourself by writing React won't stop you from making bad design decisions.


I was specifically talking about data fetching there. You can absolutely do the same kind of bad thing in an ngOnInit method.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: