Last active
August 14, 2023 09:12
-
-
Save olygood/1fbce381d7a4b04882a137f0ce4b3d32 to your computer and use it in GitHub Desktop.
react Link
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*création des liens ----------------------------------------------------------*/ | |
const PageLink = () => { | |
return ( | |
<div> | |
<NavLink exact to="/">Home</NavLink> | |
<NavLink exact to="Works">Works</NavLink> | |
<NavLink exact to="Contact">Contact</NavLink> | |
</div> | |
); | |
}; | |
export default PageLink; | |
/*création des routes/Route: liens aux pages que l'on affiche dans le main------------------------------------*/ | |
import Home from './Pages/Home'; | |
import Works from './Pages/Works'; | |
import Contact from './Pages/Contact'; | |
function PageLink() { | |
return ( | |
<Routes> | |
<Route path="/" element={<Home />}/> | |
<Route path="works" element={<Works />}/> | |
<Route path="contact" element={<Contact />}/> | |
</Routes> | |
); | |
} | |
export default PageLink; | |
/*création de BroserRouter dans App-----------------------------------------------------------------*/ | |
import {BrowserRouter,Routes,Route} from "react-router-dom"; | |
<BrowserRouter> | |
<Layout /> | |
<Routes> | |
<Route path="/" element={<Home />}/> | |
<Route path="works" element={<Works />}/> | |
<Route path="contact" element={<Contact />}/> | |
</Routes> | |
</BrowserRouter> | |
/*création d'un composant------------------------------------------------------------------------------*/ | |
import React from 'react'; | |
const Contact = () => { | |
return ( | |
<h1>je suis le Contact</h1> | |
); | |
}; | |
export default Contact; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment