23. Data flows one direction and your
application responds to changes in the
data.
Child components are not responsible for
maintaining any state. Their state passed
through the data properties from the
parent.
24. // Lets pretend `cart` is a model object of the cart.
var ShoppingCartComponent = React.createClass({
render: function() {
return <ShoppingCartListComponent cart={this.state.cart}
products={this.state.cart.products}/>
}
});
27. With this style its data down and events up.
checking state and re-rendering but rather noti
28. But wouldn’t all of this re-rendering be
expensive? The DOM is so slow!
29. It would be in a traditional application
architecture. Templates must be re-
rendered as strings and reinserted in to the
DOM after it removed the previous content.
React solves this with its most well known
feature: The Virtual DOM.
32. React keeps an in memory representation
of the DOM structure of the components.
At render time React determines the least
amount of modifications required to update
the data to the current state.
36. You can, however, access the DOM if you
need to.
var ShoppingCartComponent = React.createClass({
componentDidMount: function() {
var $el = $(this.getDOMNode());
this.setState({ width: $el.width() });
}
});
46. There are solutions for dealing with things
out side of the scope of the view and DOM.
After the release of React an architecture
pattern called Flux has emerged. It’s way
too big for this talk and I recommend you
check it out yourself.