반응형
App.tsx
import React from 'react';
import logo from './logo.svg';
import './App.css';
import BeforeLoginLayout from './Components/layouts/HomeLayout';
import {AuthenticateRoutes, UnAuthenticateRoutes} from './Components/layouts/PrivateRoute';
import { Route, useLocation, Navigate } from 'react-router-dom';
import Register from './Components/layouts/Register';
import Login from './Components/layouts/Login';
import AfterLoginLayout from './Components/layouts/AfterLoginLayout';
import LandingPage from './Components/layouts/LandingPage';
//
import { BrowserRouter as Router, Routes } from 'react-router-dom';
function App() {
return (
<div >
<Routes>
<Route element={<UnAuthenticateRoutes />}>
<Route path="/" element={<BeforeLoginLayout />}>
<Route index element={<Login />} />
<Route path="register" element={<Register />} />
</Route>
</Route>
<Route element={<AuthenticateRoutes />}>
<Route path="/admin" element={<AfterLoginLayout />} >
<Route index element={<LandingPage />} />
<Route path="test" element={<LandingPage />} />
</Route>
</Route>
</Routes>
{/* <Greeting name="John" />*/}
</div>
);
}
export default App;
index.tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { BrowserRouter } from 'react-router-dom';
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<React.StrictMode>
<BrowserRouter>
<App />
</BrowserRouter>
</React.StrictMode>
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
관련 소스
https://github.com/wahyueko22/learn-react
반응형
'실전 단아 개발 가이드' 카테고리의 다른 글
https://ui-lib.com/ 테플릿 있는 곳 (0) | 2024.02.29 |
---|---|
React Type Script 관련 팁 찾기 (0) | 2024.02.29 |
React.js Typescript application starter (0) | 2024.02.29 |
Arrow 함수 => (1) | 2024.01.30 |
react-scripts'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는배치 파일이 아닙니다. (0) | 2024.01.24 |