fixed missing ifmounted bug / fixed getting item when navigating directly to page

This commit is contained in:
Senad Uka
2015-01-28 05:04:45 +01:00
parent f27c29fccf
commit f8b3ef3a64
9 changed files with 109 additions and 92 deletions

View File

@@ -7,17 +7,9 @@ var ItemCollection = require('../../models/itemCollection');
var AllItems = React.createClass({
render: function() {
if(this.state) {
return (
<ItemList items={this.state.items} />
);
}
else {
return (
<div> Not Loaded ! </div>
);
}
},
// Add change listeners to stores
@@ -26,6 +18,14 @@ var AllItems = React.createClass({
ItemStore.addChangeListener(this._onChange);
},
getInitialState: function() {
return {
items: ItemStore.getItems()
}
},
_onChange: function () {
if (this.isMounted()) {
this.setState({