import React from 'react'; import ReactDOM from 'react-dom'; import io from 'socket.io-client'; import Board from './board'; import './index.css'; const ENDPOINT = "http://192.168.1.7:4001"; class Game extends React.Component { constructor(props) { super(props); this.state = { board: null, socket: io(ENDPOINT), }; this.state.socket.on("FromAPI", data => { console.log(data); this.setState({ board: null, }); this.setState({ board: ( { console.log("ON MOVE"); this.state.socket.emit("move", move); }}/> ), }); }); } render() { return (
{this.state.board}
); } } // ======================================== ReactDOM.render( , document.getElementById('root') );