fixed missing ifmounted bug / fixed getting item when navigating directly to page
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
var React = require('react')
|
||||
ItemWithDetailsPage = require('./itemWithDetailsPage');
|
||||
var ItemPage = React.createClass({
|
||||
render: function() {
|
||||
return (
|
||||
<div>
|
||||
<ItemWithDetailsPage />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = ItemPage;
|
||||
@@ -1,6 +1,7 @@
|
||||
var React = require('react'),
|
||||
ItemMultiMediaDescriptions = require('./itemMultiMediaDescriptions'),
|
||||
ItemActions = require('../../actions/itemActions'),
|
||||
NavigationStore = require('../../stores/NavigationStore'),
|
||||
ItemStore = require('../../stores/itemStore');
|
||||
|
||||
var Router = require('react-router');
|
||||
@@ -35,17 +36,21 @@ var ItemWithDetailsPage = React.createClass({
|
||||
// Add change listeners to stores
|
||||
componentDidMount: function() {
|
||||
ItemStore.addChangeListener(this._onChange);
|
||||
NavigationStore.addChangeListener(this._onChange);
|
||||
ItemActions.loadItemWithDetails();
|
||||
},
|
||||
|
||||
_onChange: function () {
|
||||
this.setState({
|
||||
item: ItemStore.getSelectedItem()
|
||||
});
|
||||
if (this.isMounted()) {
|
||||
this.setState({
|
||||
item: ItemStore.getLoadedItemWithDetails()
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
getInitialState: function () {
|
||||
return {
|
||||
item : ItemStore.getSelectedItem()
|
||||
item : ItemStore.getLoadedItemWithDetails()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ var SingleItem = React.createClass({
|
||||
|
||||
itemClick: function(e) {
|
||||
NavigationActions.goToItemDetails(this.props.item);
|
||||
ItemActions.selectItem(this.props.item);
|
||||
console.log(this.props.item)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user