Last active
September 24, 2015 21:56
-
-
Save benhowdle89/87b54964d7d1eed1bd68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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