Hacker News new | ask | show | jobs
by Touche 4548 days ago
I use React and like it a lot. The biggest issue it has right now is there is no good way for a component on one branch of the tree to get information to a component in another branch. You have to talk to your parent components by having them attach a function as a property, and this simply doesn't scale to large or even medium sized applications.
2 comments

This model usually works pretty well for smaller components (see http://facebook.github.io/react/blog/2013/11/05/thinking-in-...)

For larger ones, we provide lifecycle hooks so you can set up these subscriptions manually. In componentDidMount() and componentWillUnmount() you can subscribe/unsubscribe to some sort of messaging system, and when you receive the message call setState(). Usually you only need to do this in a few places and the regular React dataflow will carry you the rest of the way.

Does that make sense? We should probably write up this technique.

This isn't specific to React; in large GWT apps we use an event bus. Perhaps you could do the same thing?

Or, instead of an event-based approach, you could could pass in an object and use Object.observe() to observe state changes.

It looks like React just implements the view in MVC, so you still need a separate way to observe the model.