aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/app.js
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-12-20 13:28:12 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:52 +0300
commit813c5e7eda90944733d60dd324459ced93c9c087 (patch)
treeb3a7e40532aef4544377e66fd00a0fc5eac21671 /vnext/src/app.js
parenta12975463c3389e506d24288341b30257419d8d2 (diff)
initial demo
Diffstat (limited to 'vnext/src/app.js')
-rw-r--r--vnext/src/app.js34
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