Быстрый UI
без головной боли
Максим Кожух
 
Типичные проблемы
веб-приложений
    
    
    
Backbone
Angular
Ember
...
или нет...
Model             View        Controller

var HelloWorld = React.createClass({
  render: function(){
    return React.DOM.p("Hello world");
  }
});
React.renderComponent(
    HelloWorld(),
    document.getElementById('example')
);
return React.DOM.ul([
    React.DOM.li("Option A"),
    React.DOM.li("Option B")
])
    return "<ul><li>Option A</li><li>Option B</li></ul>";
Типичные проблемы
веб-приложений
        
    
        
    
var HelloWorld = React.createClass({
  render: function(){
    return React.DOM.p( "Hello world " + this.props.index );
  }
});
var HelloUniverse = React.createClass({
  render: function() {
    var worlds = [];
    for(var i=0; i<100; i++) 
      worlds.push( HelloWord({ index: i }));
    return React.DOM.div(worlds);
  }
});


var HelloWorld = React.createClass({
  render: function(){
    return React.DOM.p( "Hello world " + this.props.index );
  }
});
var HelloUniverse = React.createClass({
  render: function() {
    var worlds = [];
    for(var i=0; i<100; i++) 
      worlds.push( HelloWord({ index: i }));
    return React.DOM.div(worlds);
  }
});
/** @jsx React.DOM */
var HelloWorld = React.createClass({
  render: function(){
    return <p>Hello world {this.prop.index}</p>;
  }
});
var HelloUniverse = React.createClass({
  render: function() {
    var worlds = [];
    for(var i=0; i<100; i++) 
      worlds.push( <HelloWorld index={i} />  );
    return <div>(worlds)</div>;
  }
});
Самый сложный пример
var HelloUniverse = React.createClass({
  getInitialState:function(){
    return { start: 0; } 
  },
  shiftNext:function(){
    this.setState({ start : this.state.start + 1 });
  },
  render: function() {
    var worlds = [];
    var start = this.start.state;
    for(var i=start; i<start + 10000; i++) 
      worlds.push( <HelloWorld index={i} onClick={this.onClick} />  );
    return <div onClick={this.shiftNext}>(worlds)</div>;
  }
});
Самый сложный пример - State
var HelloUniverse = React.createClass({
  getInitialState:function(){
    return { start: 0; } 
  },
  shiftNext:function(){
    this.setState({ start : this.state.start + 1 });
  },
  render: function() {
    var worlds = [];
    var start = this.start.state;
Самый сложный пример
  render: function() {
    var worlds = [];
    var start = this.start.state;
    for(var i=start; i<start + 10000; i++) 
      worlds.push( <HelloWorld index={i} onClick={this.onClick} />  );
    return <div onClick={this.shiftNext}>(worlds)</div>;
  }
});
Типичные проблемы
веб-приложений
        
    
        
    


 
     

 
