import React, {useState} from 'react'; import './App.scss'; import config from './config'; import { Switch, Route } from 'react-router-dom'; import socketIOClient from 'socket.io-client'; import Account from './pages/Account/Account'; import Game from './pages/Game/Game'; import Home from './pages/Home/Home'; import News from './pages/News/News'; import Room from './pages/Room/Room'; export const socket = socketIOClient(config.apiAddress); function App() { const [fetchData, setFetchData] = useState(); const [socketData, setSocketData] = useState(); fetch(config.apiAddress).then(res => res.text()).then(data => setFetchData(data)); socket.emit('connect'); socket.on('connected', data => setSocketData(data.message)); return (

React Boilerplate

{fetchData ?

{fetchData}

: <>} {socketData ?

{socketData}

: <>} {/* Add ternary for login */}
); } export default App;