Last active
August 29, 2015 14:21
-
-
Save lhahne/2ca9720cd109ca335b67 to your computer and use it in GitHub Desktop.
react view
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
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