import React, { useEffect, useState } from 'react'; import './App.css'; import { Client } from './client'; import { createBrowserRouter, RouterProvider } from 'react-router-dom'; import { GmView } from './views/GmView/GmView'; import { WebsocketProvider } from './components/WebsocketProvider'; import { PlayerView } from './views/PlayerView/PlayerView'; interface AppProps { client: Client; } const App = ({ client }: AppProps) => { console.log("rendering app"); const [websocketUrl, setWebsocketUrl] = useState(undefined); useEffect(() => { client.registerWebsocket().then((url) => setWebsocketUrl(url)) }, [client]); let router = createBrowserRouter([ { path: "/gm", element: websocketUrl ? :
}, { path: "/", element: websocketUrl ? :
} ]); return (
); } export default App;