js'use strict';
var React = require('react');
var NewsItemComponent = React.createClass({
render: function() {
return (
{this.props.title}
{this.props.content}
);
}
});
var NewsListComponent = React.createClass({
getInitialState: function() {
return {newsList: []}
},
componentDidMount: function() {
document.addEventListener('scroll', this.handleScroll);
},
componentWillUnmount: function() {
document.removeEventListener('scroll', this.handleScroll);
},
addNews: function(news) {
this.setState({newsList: this.state.newsList.concat(news)});
},
handleScroll: function() {
if (isBottom) {
ajax.request('api').then(this.addNews);
}
},
render: function() {
var newsList = this.state.newsList.map(function(news) {
return ;
});
return (
{newsList}
);
}
});