Skip to content

Instantly share code, notes, and snippets.

@Nosherwan
Created November 1, 2015 22:24
Show Gist options
  • Save Nosherwan/5082bdc56df49bed421a to your computer and use it in GitHub Desktop.
Save Nosherwan/5082bdc56df49bed421a to your computer and use it in GitHub Desktop.
React Home Component
import React from 'react';
import ArticleStore from '../stores/ArticleStore';
import ArticleList from './articleList';
class Home extends React.Component {
constructor(props) {
super(props);
var params = this.props.params;
this.state = {articles: ArticleStore.getAll()};
}
_onChange() {
var articles = ArticleStore.getAll();
this.setState({articles: articles});
}
componentWillMount() {
ArticleStore.addChangeListener(this._onChange);
}
componentWillUnmount() {
ArticleStore.removeChangeListener(this._onChange);
}
render() {
return (<div>
<ArticleList list={this.state.articles}></ArticleList>
</div>)
}
}
export default Home;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment