import "whatwg-fetch" import React from "react" import PropTypes from "prop-types" import ReactDOM from "react-dom" import Message from "./components/Message" class Page extends React.Component { constructor(props) { super(props) this.state = {msgs: [], loading: false} } render() { var nodes = this.state.msgs.map(msg => { return () }); return (
{nodes}
) } componentDidMount() { fetch(this.props.source) .then(response => { return response.json() }) .then(data => this.setState({ msgs: data }) ).catch(ex => { console.log(ex) }); } }; Page.propTypes = { msgs: PropTypes.array, source: PropTypes.string.isRequired } ReactDOM.render(, document.getElementById("content"));