fixed missing ifmounted bug / fixed getting item when navigating directly to page
This commit is contained in:
@@ -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()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user