Toggle navigation
Toggle navigation
This project
Loading...
Sign in
강동현
/
nodejs-game
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Overnap
2021-05-26 20:09:49 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
836497799bc346397c5b63dcf9d97f3e23d1693c
83649779
1 parent
773e0ed4
루트 컴포넌트에 라우터와 소켓 컨텍스트 추가
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
17 deletions
web/src/App.tsx
web/src/SocketContext.ts
web/src/App.tsx
View file @
8364977
import React from 'react';
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom';
import { socket, SocketProvider } from './SocketContext';
import { Login } from './Login';
function App()
{
const App: React.FC = () =>
{
return (
<div className="App">
<div className="ml-3 mb-3 font-bold text-2xl">TESTING</div>
<header className="App-header">
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
<SocketProvider value={socket}>
<Router>
<Switch>
<Route exact path='/' component={Login}/>
<Route path='/rooms'></Route>
<Route path='/:roomId'></Route>
</Switch>
</Router>
</SocketProvider>
);
}
...
...
web/src/SocketContext.ts
0 → 100644
View file @
8364977
import
React
from
'react'
;
import
{
io
}
from
'socket.io-client'
;
export
const
socket
=
io
(
'http://localhost/'
);
const
SocketContext
=
React
.
createContext
(
socket
);
export
const
SocketProvider
=
SocketContext
.
Provider
;
export
const
SocketConsumer
=
SocketContext
.
Consumer
;
export
default
SocketContext
;
Please
register
or
login
to post a comment