react frontend app (display screen, join)
This commit is contained in:
parent
1a20fa1fb6
commit
abdfdf2ec0
1 changed files with 3917 additions and 5 deletions
22
tank-frontend/src/index.tsx
Normal file
22
tank-frontend/src/index.tsx
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import React, {useState} from 'react';
|
||||
import './index.css';
|
||||
import ClientScreen from './ClientScreen';
|
||||
import Controls from './Controls.tsx';
|
||||
import JoinForm from './JoinForm.tsx';
|
||||
import {createRoot} from 'react-dom/client';
|
||||
|
||||
function App() {
|
||||
const [id, setId] = useState<string | null>(null);
|
||||
|
||||
return <>
|
||||
{id === null && <JoinForm onDone={name => setId(name)}/>}
|
||||
<ClientScreen/>
|
||||
{id == null || <Controls playerId={id}/>}
|
||||
</>;
|
||||
}
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<React.StrictMode>
|
||||
<App/>
|
||||
</React.StrictMode>
|
||||
);
|
||||
Reference in a new issue