Created
October 31, 2021 10:47
-
-
Save Reine0017/ae846f7e6634f4230c8a11da0badf113 to your computer and use it in GitHub Desktop.
To show how to redirect with react-router-dom
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
| import React from 'react'; | |
| import { | |
| Switch, | |
| Route, | |
| BrowserRouter as Router, | |
| } from "react-router-dom"; | |
| import NavBar from './components/NavBar'; | |
| import HomePage from './pages/homePage/HomePage'; | |
| import ReactPortalPage from './pages/reactPortalPage/ReactPortalPage'; | |
| import SomePage from './pages/somePage/SomePage'; | |
| import './App.css'; | |
| function App() { | |
| return ( | |
| <div className="App"> | |
| <Router> | |
| <NavBar></NavBar> | |
| <Switch> | |
| <Route exact path="/"> | |
| <HomePage/> | |
| </Route> | |
| <Route path="/react-portal"> | |
| <ReactPortalPage/> | |
| </Route> | |
| <Route path="/somepage"> | |
| <SomePage/> | |
| </Route> | |
| </Switch> | |
| </Router> | |
| </div> | |
| ); | |
| } | |
| export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment