aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/src/app.js')
-rw-r--r--vnext/src/app.js27
1 files changed, 15 insertions, 12 deletions
diff --git a/vnext/src/app.js b/vnext/src/app.js
index 52f35076..7971c71f 100644
--- a/vnext/src/app.js
+++ b/vnext/src/app.js
@@ -1,23 +1,21 @@
import "whatwg-fetch"
-import React, {PropTypes} from "react"
+import React from "react"
+import PropTypes from "prop-types"
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
- },
+class Page extends React.Component {
+ constructor(props) {
+ super(props)
+ this.state = {msgs: [], loading: false}
+ }
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 => {
@@ -29,6 +27,11 @@ const Page = React.createClass({
console.log(ex)
});
}
-});
+};
+
+Page.propTypes = {
+ msgs: PropTypes.array,
+ source: PropTypes.string.isRequired
+}
-ReactDOM.render(<Page source="https://api.juick.com/messages" />, document.getElementById("content")); \ No newline at end of file
+ReactDOM.render(<Page source="https://api.juick.com/messages" />, document.getElementById("content"));