Add Routing on the app

This commit is contained in:
Charles Bochet
2022-12-02 12:39:15 +01:00
parent 017df9dae2
commit eba76274c6
7 changed files with 101 additions and 67 deletions

View File

@ -1,38 +0,0 @@
.App {
text-align: center;
}
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

View File

@ -1,24 +1,15 @@
import React from 'react';
import logo from './logo.svg';
import './App.css';
import Tasks from './pages/Tasks';
import History from './pages/History';
import { Routes, Route } from 'react-router-dom';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<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>
<Routes>
<Route path="/" element={<Tasks />} />
<Route path="/history" element={<History />} />
</Routes>
</div>
);
}

View File

@ -2,12 +2,13 @@ import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import { BrowserRouter } from 'react-router-dom';
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement,
);
root.render(
<React.StrictMode>
<BrowserRouter>
<App />
</React.StrictMode>,
</BrowserRouter>,
);

View File

@ -0,0 +1,9 @@
function History() {
return (
<div>
<h1>This is the history page</h1>
</div>
);
}
export default History;

View File

@ -0,0 +1,9 @@
function Tasks() {
return (
<div>
<h1>This is the home page</h1>
</div>
);
}
export default Tasks;