Skip to content

Instantly share code, notes, and snippets.

@benhowdle89
Last active September 24, 2015 21:56
Show Gist options
  • Save benhowdle89/87b54964d7d1eed1bd68 to your computer and use it in GitHub Desktop.
Save benhowdle89/87b54964d7d1eed1bd68 to your computer and use it in GitHub Desktop.
import React from 'react';
import ItemsCollection from './../collections/items';
const Items = React.createClass({
getInitialState() {
return {
items: []
};
},
componentDidMount() {
ItemsCollection.on('add remove', this.updateItems);
(ItemsCollection.length) ? this.updateItems() : ItemsCollection.fetch();
},
updateItems() {
this.setState({
items: ItemsCollection.toJSON()
});
},
render() {
return (
<div>
{
this.state.items.map((item) => {
return <div>
<a href="#">{item.name}</a>
</div>
})
}
</div>
);
}
});
export default Items;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment