import React from 'react'; export default class Env extends React.Component { constructor(props) { super(props); this.state = { commandLine: [], env: {} }; } loadState() { fetch(this.props.apiPath) .then(response => response.json()) .then(response => this.setState(response)); } componentDidMount() { this.loadState() } render () { let args = []; for (let [idx, arg] of this.state.commandLine.entries()) { args.push({arg}) args.push(" ") } let rows = []; for (let k in this.state.env) { rows.push( {k} {this.state.env[k]} ) } return (
Command Line
{args}
{rows}
KeyValue
) } } Env.propTypes = { apiPath: React.PropTypes.string.isRequired, }