diff --git a/web/src/App.tsx b/web/src/App.tsx index a914432..f02aa60 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -1,15 +1,17 @@ import React from "react"; -import { io } from "socket.io-client"; +import { Socket } from "socket.io-client"; import LandingPage from "./pages/landing/LandingPage"; -function App() { - const socket = io("http://localhost:3010"); - - return ( -
- -
- ); +export interface AppProps { + socket: Socket; } +const App = (props: AppProps) => { + return ( +
+ +
+ ); +}; + export default App; diff --git a/web/src/index.tsx b/web/src/index.tsx index dd89d8c..74b954e 100644 --- a/web/src/index.tsx +++ b/web/src/index.tsx @@ -2,12 +2,14 @@ import React from "react"; import ReactDOM from "react-dom/client"; import App from "./App"; import "./App.scss"; +import { io } from "socket.io-client"; const root = ReactDOM.createRoot( document.getElementById("root") as HTMLElement, ); +const socket = io("http://localhost:3010"); root.render( - + , ); diff --git a/web/src/pages/landing/LandingPage.tsx b/web/src/pages/landing/LandingPage.tsx index afe7c7c..6b472f9 100644 --- a/web/src/pages/landing/LandingPage.tsx +++ b/web/src/pages/landing/LandingPage.tsx @@ -7,8 +7,12 @@ import { import React, { ChangeEvent } from "react"; import { Socket } from "socket.io-client"; -const LandingPage = (props: { socket: Socket }) => { - const socket = props.socket; +export interface LandingPageProps { + socket: Socket; +} + +const LandingPage = (props: LandingPageProps) => { + const { socket } = props; const createLobbyPayload: CreateLobbyEvent = { userName: "" }; const joinLobbyPayload: JoinLobbyEvent = { userName: "", lobbyId: "" }; @@ -21,25 +25,25 @@ const LandingPage = (props: { socket: Socket }) => { return ( -
+

Trains And Roads

-
+
-
+
-
+