import React from 'react'; import FullNode from "./FullNode"; import ConnMgr from "./ConnMgr"; class NodeList extends React.Component { constructor(props) { super(props) this.state = { existingLoaded: false, nodes: [], showConnMgr: false, } // This binding is necessary to make `this` work in the callback this.spawnNode = this.spawnNode.bind(this) this.connMgr = this.connMgr.bind(this) this.props.client.call('Pond.Nodes').then(nodes => this.setState({existingLoaded: true, nodes: nodes})) } async spawnNode() { const node = await this.props.client.call('Pond.Spawn') console.log(node) this.setState(state => ({nodes: state.nodes.concat(node)})) } connMgr() { this.setState({showConnMgr: true}) } render() { let connMgr if (this.state.showConnMgr) { connMgr = () } return (
{ this.state.nodes.map((node, i) => { return () }) } {connMgr}
); } } export default NodeList