P.3 - ݅දࣔ
/** @jsx React.DOM */
App = React.createClass({
getInitialState: function() {
return {
newText: "",
items: [
{ text: "Foo" },
{ text: "Bar" },
{ text: "Buzz" }
]
};
},
addItem: function() {
event.preventDefault();
this.setState({
items: [{text : this.state.newText}].concat(this.state.items),
newText: ""
})
},
updateNewText: function(ev) {
this.setState({
newText : ev.target.value
});
},
render: function() {
return
Ճ
{this.state.items.length}݅
{this.state.items.map(function(item) {
return
{item.text}
;
})}
;
}
});
React.render(, document.body);