Server
Client
Server
Client
Framework/Library | Routing | Two-way binding | Modules | Views |
Angular | X | X | X | X |
Backbone | X | X | ||
Knockout | X | X | ||
React | X |
var First = React.createClass({
render: function () {
return (
<p>My first component!</p>
);
}
});
var Counter = React.createClass({
getInitialState: function () {
return {
count: 0
};
},
increaseCount: function () {
this.setState({
count: this.state.count + 1
});
},
render: function () {
return (
<button onClick={this.increaseCount}>
You clicked {this.state.count} times!
</button>
);
}
});
var Counter = React.createClass({
// ...
});
React.render(
<Counter />,
document.body
);
var Child = React.createClass({
render: function () {
return (
<p>{this.props.text}</p>
);
}
});
var Parent = React.createClass({
render: function () {
return (
<div className="container">
<Child text="Pass this to the child component" />
</div>
);
}
});
var Child = React.createClass({
onDeleteClick: function () {
this.props.onDelete();
},
render: function () {
return (
<button onClick={this.onDeleteClick}>
Delete
</button>
);
}
});
var Parent = React.createClass({
onChildDelete: function (childData) {
backend.delete(childData);
},
render: function () {
var childData = { /* ... */ };
return (
<Child onDelete={this.onChildDelete.bind(this, childData)} />
);
}
});