What is workflow of the react.js?
//The below code is the example of react.js which updates the DOM
dynamically. I used //the tutorial by facebook react but did not
understand the whole code, i.e which part of //the code executes when and
how it triggers the rest of the parts in the code. So kindly //help in
understanding the code. var TodoList = React.createClass({ render:
function() { var createItem = function(itemText) { return
{itemText}
; }; return
{this.props.items.map(createItem)}
; } }); var TodoApp = React.createClass({ getInitialState: function() {
return {items: [], text: ''}; }, onChange: function(e) {
this.setState({text: e.target.value}); }, handleSubmit: function(e) {
e.preventDefault(); var nextItems =
this.state.items.concat([this.state.text]); var nextText = '';
this.setState({items: nextItems, text: nextText}); }, render: function() {
return (
TODO
{'Add #' + (this.state.items.length + 1)} ); } }); React.renderComponent(,
mountNode);
//The above code is used to dynamically update the DOM structure. This
code is referred // from http://facebook.github.io/react/
//so please in knowing the work process of the code.
No comments:
Post a Comment