Skip to content

Instantly share code, notes, and snippets.

@lhahne
Last active August 29, 2015 14:21
Show Gist options
  • Save lhahne/2ca9720cd109ca335b67 to your computer and use it in GitHub Desktop.
Save lhahne/2ca9720cd109ca335b67 to your computer and use it in GitHub Desktop.
react view
var React = require('react')
var StationMetadataStore = require('./StationMetadataStore')
var StationList = React.createClass({
getInitialState() {
return {stations: []}
},
componentDidMount: function() {
this.unsubscribe =
StationMetadataStore.stationsByCode.onValue(stationCodes => {
this.setState({
stationCodes: stationCodes
})
})
},
componentWillUnmount: function() {
this.unsubscribe()
},
render() {
var renderRows = rows =>
rows.map((row) => <li>{row.stationShortCode}: {row.stationName}</li>)
return <ul>{renderRows(this.state.stationCodes)}</ul>
}
})
React.render(<StationList/>, document.getElementById('appRoot'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment