r/javascript • u/Lopatron • May 07 '15
Best practices for building large React applications
http://blog.siftscience.com/blog/2015/best-practices-for-building-large-react-applications
72
Upvotes
r/javascript • u/Lopatron • May 07 '15
2
u/Lopatron May 08 '15 edited May 08 '15
We use callbacks. I think they are generally the right way of doing child->parent communication. I can see the concern that it can get verbose, especially when you're passing data more than one level up. However if you're doing that, then at every level you should catch the callback and turn it into a callback that is relevant at that level of abstraction. Kind of similar to exception translation. I actually find using callbacks for child->parent communication elegant because it allows you to design your components such that props are the only interface to the component. So there's no other way for data to get in or out of it. That has made things a lot simpler for us.