Files
old-ribica/front-ui/app/components/items/allItems.js

39 lines
843 B
JavaScript
Raw Normal View History

2015-01-25 10:26:10 +01:00
var React = require('react');
var ItemList = require('./itemList');
2015-01-25 14:04:10 +01:00
var ItemStore = require('../../stores/itemStore.js');
var ItemActions = require('../../actions/itemActions.js');
var ItemCollection = require('../../models/itemCollection');
2015-01-25 10:26:10 +01:00
var AllItems = React.createClass({
2015-01-25 16:42:16 +01:00
render: function() {
return (
<ItemList items={this.state.items} />
2015-01-25 10:26:10 +01:00
);
2015-01-25 16:42:16 +01:00
},
// Add change listeners to stores
2015-01-25 10:26:10 +01:00
componentDidMount: function() {
2015-01-25 16:42:16 +01:00
ItemActions.loadFrontPageItems();
ItemStore.addChangeListener(this._onChange);
2015-01-25 10:26:10 +01:00
},
getInitialState: function() {
return {
items: ItemStore.getItems()
}
},
2015-01-25 10:26:10 +01:00
_onChange: function () {
if (this.isMounted()) {
this.setState({
2015-01-25 16:42:16 +01:00
items: ItemStore.getItems()
2015-01-25 10:26:10 +01:00
});
}
},
});
module.exports = AllItems;