Created
November 1, 2015 22:24
-
-
Save Nosherwan/5082bdc56df49bed421a to your computer and use it in GitHub Desktop.
React Home Component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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