(no title)
enginous | 12 years ago
The format of the post is also quite nice; a few short points with illustrations and a clear takeaway.
enginous | 12 years ago
The format of the post is also quite nice; a few short points with illustrations and a clear takeaway.
Touche|12 years ago
peterhunt|12 years ago
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.
skybrian|12 years ago
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.
tomhallett|12 years ago
The part of the architecture which has had the biggest impact on my code: the relationship between a component and it's subcomponents. A parent component can only pass "props" to it's subcomponents (ie it can't pass state, which is easily mutable). And a child component can only call a function on it's parent if that function is provided to it via props (ie a callback).
This design has forced me to reason about the interface between components (open/closed principle, law of demeter, etc) and has really improved my code.
Also, the team is very active/helpful in their irc room.