// following along http://facebook.github.io/react/docs/tutorial.html
import React from "react";
import marked from "marked";
require('./style.css');
class CommentForm extends React.Component {
render() {
return (
I might be an actual form someday...
);
}
}
class CommentList extends React.Component {
render() {
let commentNodes = this.props.data.map((comment) => {
return (
{comment.text}
);
});
return (
{commentNodes}
);
}
}
class CommentBox extends React.Component {
constructor(props) {
super(props);
this.state = {data: []}
}
componentDidMount() {
let xhr = new XMLHttpRequest();
xhr.open('GET', this.props.url);
xhr.onreadystatechange = function() {
if (xhr.readyState == XMLHttpRequest.DONE) {
this.setState({data: JSON.parse(xhr.responseText)});
}
}.bind(this);
xhr.onerror = function(err) {
console.error(this.props.url, xhr.status, err);
}.bind(this);
xhr.send();
}
render() {
return (
Comments
);
}
}
class Comment extends React.Component {
render() {
let rawMarkup = marked(this.props.children.toString());
return (
{this.props.author}
);
}
}
React.render(, document.getElementById("content"));