import { StrictMode, Suspense, lazy, useEffect } from 'react'; import { createRoot } from 'react-dom/client'; import { BrowserRouter, Route, Routes, useLocation, useNavigate } from 'react-router'; import 'pretendard/dist/web/variable/pretendardvariable-dynamic-subset.css'; import './styles/global.css'; import { ConnectionBanner, Toasts } from './components/ui'; import { useSession } from './store/session'; import { toast } from './store/toast'; import { Home } from './pages/Home'; const JoinPage = lazy(() => import('./pages/JoinPage')); const RoomPage = lazy(() => import('./pages/RoomPage')); const GamePage = lazy(() => import('./pages/GamePage')); const MePage = lazy(() => import('./pages/MePage')); const RulesPage = lazy(() => import('./pages/RulesPage')); const NotFound = lazy(() => import('./pages/NotFound')); function Shell() { const loaded = useSession((s) => s.loaded); const nav = useNavigate(); const loc = useLocation(); useEffect(() => { void useSession.getState().refresh(); const onUnauthorized = () => void useSession.getState().refresh(); window.addEventListener('bg:unauthorized', onUnauthorized); return () => window.removeEventListener('bg:unauthorized', onUnauthorized); }, []); useEffect(() => { const q = new URLSearchParams(loc.search); if (q.get('linked') === '1') toast('디스코드 계정과 연결했어요.'); if (q.get('login') === 'failed') toast('디스코드 로그인에 실패했어요. 다시 시도해 주세요.', 'error'); if (q.has('linked') || q.has('login')) { q.delete('linked'); q.delete('login'); nav({ pathname: loc.pathname, search: q.toString() }, { replace: true }); } }, [loc.search]); // eslint-disable-line react-hooks/exhaustive-deps if (!loaded) return
불러오는 중…
; return ( <> 불러오는 중…}> } /> } /> } /> } /> } /> } /> } /> ); } createRoot(document.getElementById('root')!).render( , );