diff options
Diffstat (limited to 'vnext/src/app.js')
-rw-r--r-- | vnext/src/app.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/vnext/src/app.js b/vnext/src/app.js new file mode 100644 index 00000000..52f35076 --- /dev/null +++ b/vnext/src/app.js @@ -0,0 +1,34 @@ +import "whatwg-fetch" +import React, {PropTypes} from "react" +import ReactDOM from "react-dom" + +import Message from "./components/Message.jsx" + +const Page = React.createClass({ + getInitialState() { + return {msgs: [], loading: false} + }, + propTypes: { + msgs: PropTypes.array, + source: PropTypes.string.isRequired + }, + render() { + var nodes = this.state.msgs.map(msg => { + return (<Message key={msg.mid} mid={msg.mid} user={msg.user} body={msg.body} timestamp={msg.timestamp}/>) + }); + return (<div className="msgs">{nodes}</div>) + }, + componentDidMount() { + fetch(this.props.source) + .then(response => { + return response.json() + }) + .then(data => + this.setState({ msgs: data }) + ).catch(ex => { + console.log(ex) + }); + } +}); + +ReactDOM.render(<Page source="https://api.juick.com/messages" />, document.getElementById("content"));
\ No newline at end of file |