|
|
@ -22,7 +22,7 @@
|
|
|
|
- [What is React Router ?](#what-is-react-router-)
|
|
|
|
- [What is React Router ?](#what-is-react-router-)
|
|
|
|
- [BroswerRouter](#broswerrouter)
|
|
|
|
- [BroswerRouter](#broswerrouter)
|
|
|
|
- [Route](#route)
|
|
|
|
- [Route](#route)
|
|
|
|
- [Switch](#switch)
|
|
|
|
- [Routes](#Routes)
|
|
|
|
- [NavLink](#navlink)
|
|
|
|
- [NavLink](#navlink)
|
|
|
|
- [Nested Routing](#nested-routing)
|
|
|
|
- [Nested Routing](#nested-routing)
|
|
|
|
- [Redirect](#redirect)
|
|
|
|
- [Redirect](#redirect)
|
|
|
@ -54,7 +54,7 @@ import {
|
|
|
|
BrowserRouter,
|
|
|
|
BrowserRouter,
|
|
|
|
Route,
|
|
|
|
Route,
|
|
|
|
NavLink,
|
|
|
|
NavLink,
|
|
|
|
Switch,
|
|
|
|
Routes,
|
|
|
|
Redirect,
|
|
|
|
Redirect,
|
|
|
|
Prompt,
|
|
|
|
Prompt,
|
|
|
|
withRouter,
|
|
|
|
withRouter,
|
|
|
@ -116,7 +116,7 @@ class App extends Component {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Router>
|
|
|
|
<Router>
|
|
|
|
<div className='App'>
|
|
|
|
<div className='App'>
|
|
|
|
<Route path='/home' component={Home} />
|
|
|
|
<Route path='/home' element={<Home />} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Router>
|
|
|
|
</Router>
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -152,10 +152,10 @@ class App extends Component {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Router>
|
|
|
|
<Router>
|
|
|
|
<div className='App'>
|
|
|
|
<div className='App'>
|
|
|
|
<Route path='/home' component={Home} />
|
|
|
|
<Route path='/home' element={<Home />} />
|
|
|
|
<Route path='/about' component={About} />
|
|
|
|
<Route path='/about' element={<About />} />
|
|
|
|
<Route path='/contact' component={Contact} />
|
|
|
|
<Route path='/contact' element={<Contact />} />
|
|
|
|
<Route path='/challenges' component={Challenges} />
|
|
|
|
<Route path='/challenges' element={<Challenges />} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Router>
|
|
|
|
</Router>
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -191,10 +191,10 @@ class App extends Component {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Router>
|
|
|
|
<Router>
|
|
|
|
<div className='App'>
|
|
|
|
<div className='App'>
|
|
|
|
<Route path='/' component={Home} />
|
|
|
|
<Route path='/' element={<Home />} />
|
|
|
|
<Route path='/about' component={About} />
|
|
|
|
<Route path='/about' element={<About />} />
|
|
|
|
<Route path='/contact' component={Contact} />
|
|
|
|
<Route path='/contact' element={<Contact />} />
|
|
|
|
<Route path='/challenges' component={Challenges} />
|
|
|
|
<Route path='/challenges' element={<Challenges />} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Router>
|
|
|
|
</Router>
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -230,10 +230,10 @@ class App extends Component {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Router>
|
|
|
|
<Router>
|
|
|
|
<div className='App'>
|
|
|
|
<div className='App'>
|
|
|
|
<Route exact path='/' component={Home} />
|
|
|
|
<Route exact path='/' element={<Home />} />
|
|
|
|
<Route exact path='/about' component={About} />
|
|
|
|
<Route exact path='/about' element={<About />} />
|
|
|
|
<Route exact path='/contact' component={Contact} />
|
|
|
|
<Route exact path='/contact' element={<Contact />} />
|
|
|
|
<Route exact path='/challenges' component={Challenges} />
|
|
|
|
<Route exact path='/challenges' element={<Challenges />} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Router>
|
|
|
|
</Router>
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -269,10 +269,10 @@ class App extends Component {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Router>
|
|
|
|
<Router>
|
|
|
|
<div className='App'>
|
|
|
|
<div className='App'>
|
|
|
|
<Route exact path='/' component={Home} />
|
|
|
|
<Route exact path='/' element={<Home />} />
|
|
|
|
<Route exact strict path='/about' component={About} />
|
|
|
|
<Route exact strict path='/about' element={<About />} />
|
|
|
|
<Route exact strict path='/contact' component={Contact} />
|
|
|
|
<Route exact strict path='/contact' element={<Contact />} />
|
|
|
|
<Route exact strict path='/challenges' component={Challenges} />
|
|
|
|
<Route exact strict path='/challenges' element={<Challenges />} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Router>
|
|
|
|
</Router>
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -283,16 +283,16 @@ const rootElement = document.getElementById('root')
|
|
|
|
ReactDOM.render(<App />, rootElement)
|
|
|
|
ReactDOM.render(<App />, rootElement)
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
The other way to avoid the lingering home page is rearranging the routing order and Switch component. Just putting the home route at the bottom.
|
|
|
|
The other way to avoid the lingering home page is rearranging the routing order and Routes component. Just putting the home route at the bottom.
|
|
|
|
|
|
|
|
|
|
|
|
## Switch
|
|
|
|
## Routes
|
|
|
|
|
|
|
|
|
|
|
|
The Switch component allows only on component to be rendered.
|
|
|
|
The Routes component allows only on component to be rendered.
|
|
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
```js
|
|
|
|
import React, { Component } from 'react'
|
|
|
|
import React, { Component } from 'react'
|
|
|
|
import ReactDOM from 'react-dom'
|
|
|
|
import ReactDOM from 'react-dom'
|
|
|
|
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'
|
|
|
|
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom'
|
|
|
|
|
|
|
|
|
|
|
|
// Home component
|
|
|
|
// Home component
|
|
|
|
const Home = (props) => <h1>Welcome Home</h1>
|
|
|
|
const Home = (props) => <h1>Welcome Home</h1>
|
|
|
@ -312,12 +312,12 @@ class App extends Component {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Router>
|
|
|
|
<Router>
|
|
|
|
<div className='App'>
|
|
|
|
<div className='App'>
|
|
|
|
<Switch>
|
|
|
|
<Routes>
|
|
|
|
<Route exact path='/about' component={About} />
|
|
|
|
<Route exact path='/about' element={<About />} />
|
|
|
|
<Route exact path='/contact' component={Contact} />
|
|
|
|
<Route exact path='/contact' element={<Contact />} />
|
|
|
|
<Route exact path='/challenges' component={Challenges} />
|
|
|
|
<Route exact path='/challenges' element={<Challenges />} />
|
|
|
|
<Route exact path='/' component={Home} />
|
|
|
|
<Route exact path='/' element={<Home />} />
|
|
|
|
</Switch>
|
|
|
|
</Routes>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Router>
|
|
|
|
</Router>
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -340,7 +340,7 @@ import ReactDOM from 'react-dom'
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
BrowserRouter as Router,
|
|
|
|
BrowserRouter as Router,
|
|
|
|
Route,
|
|
|
|
Route,
|
|
|
|
Switch,
|
|
|
|
Routes,
|
|
|
|
NavLink,
|
|
|
|
NavLink,
|
|
|
|
} from 'react-router-dom'
|
|
|
|
} from 'react-router-dom'
|
|
|
|
|
|
|
|
|
|
|
@ -368,12 +368,12 @@ class App extends Component {
|
|
|
|
</li>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
<Switch>
|
|
|
|
<Routes>
|
|
|
|
<Route path='/about' component={About} />
|
|
|
|
<Route path='/about' element={<About />} />
|
|
|
|
<Route path='/contact' component={Contact} />
|
|
|
|
<Route path='/contact' element={<Contact />} />
|
|
|
|
<Route path='/challenges' component={Challenges} />
|
|
|
|
<Route path='/challenges' element={<Challenges />} />
|
|
|
|
<Route path='/' component={Home} />
|
|
|
|
<Route path='/' element={<Home />} />
|
|
|
|
</Switch>
|
|
|
|
</Routes>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Router>
|
|
|
|
</Router>
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -392,7 +392,7 @@ import ReactDOM from 'react-dom'
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
BrowserRouter as Router,
|
|
|
|
BrowserRouter as Router,
|
|
|
|
Route,
|
|
|
|
Route,
|
|
|
|
Switch,
|
|
|
|
Routes,
|
|
|
|
NavLink,
|
|
|
|
NavLink,
|
|
|
|
} from 'react-router-dom'
|
|
|
|
} from 'react-router-dom'
|
|
|
|
|
|
|
|
|
|
|
@ -429,12 +429,12 @@ class App extends Component {
|
|
|
|
</li>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
<Switch>
|
|
|
|
<Routes>
|
|
|
|
<Route path='/about' component={About} />
|
|
|
|
<Route path='/about' element={<About />} />
|
|
|
|
<Route path='/contact' component={Contact} />
|
|
|
|
<Route path='/contact' element={<Contact />} />
|
|
|
|
<Route path='/challenges' component={Challenges} />
|
|
|
|
<Route path='/challenges' element={<Challenges />} />
|
|
|
|
<Route path='/' component={Home} />
|
|
|
|
<Route path='/' element={<Home />} />
|
|
|
|
</Switch>
|
|
|
|
</Routes>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Router>
|
|
|
|
</Router>
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -453,7 +453,7 @@ import ReactDOM from 'react-dom'
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
BrowserRouter as Router,
|
|
|
|
BrowserRouter as Router,
|
|
|
|
Route,
|
|
|
|
Route,
|
|
|
|
Switch,
|
|
|
|
Routes,
|
|
|
|
NavLink,
|
|
|
|
NavLink,
|
|
|
|
} from 'react-router-dom'
|
|
|
|
} from 'react-router-dom'
|
|
|
|
|
|
|
|
|
|
|
@ -490,13 +490,13 @@ class App extends Component {
|
|
|
|
</li>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
<Switch>
|
|
|
|
<Routes>
|
|
|
|
<Route path='/about' component={About} />
|
|
|
|
<Route path='/about' element={<About />} />
|
|
|
|
<Route path='/contact' component={Contact} />
|
|
|
|
<Route path='/contact' element={<Contact />} />
|
|
|
|
<Route path='/challenge' component={Challenges} />
|
|
|
|
<Route path='/challenge' element={<Challenges />} />
|
|
|
|
<Route path='/' component={Home} />
|
|
|
|
<Route path='/' element={<Home />} />
|
|
|
|
<Route component={NotFound} />
|
|
|
|
<Route component={NotFound} />
|
|
|
|
</Switch>
|
|
|
|
</Routes>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Router>
|
|
|
|
</Router>
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -515,7 +515,7 @@ import ReactDOM from 'react-dom'
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
BrowserRouter as Router,
|
|
|
|
BrowserRouter as Router,
|
|
|
|
Route,
|
|
|
|
Route,
|
|
|
|
Switch,
|
|
|
|
Routes,
|
|
|
|
NavLink,
|
|
|
|
NavLink,
|
|
|
|
} from 'react-router-dom'
|
|
|
|
} from 'react-router-dom'
|
|
|
|
|
|
|
|
|
|
|
@ -554,13 +554,13 @@ class App extends Component {
|
|
|
|
<Router>
|
|
|
|
<Router>
|
|
|
|
<div className='App'>
|
|
|
|
<div className='App'>
|
|
|
|
<Navbar />
|
|
|
|
<Navbar />
|
|
|
|
<Switch>
|
|
|
|
<Routes>
|
|
|
|
<Route component={NotFound} />
|
|
|
|
<Route component={NotFound} />
|
|
|
|
<Route path='/about' component={About} />
|
|
|
|
<Route path='/about' element={<About />} />
|
|
|
|
<Route path='/contact' component={Contact} />
|
|
|
|
<Route path='/contact' element={<Contact />} />
|
|
|
|
<Route path='/challenge' component={Challenges} />
|
|
|
|
<Route path='/challenge' element={<Challenges />} />
|
|
|
|
<Route exact path='/' component={Home} />
|
|
|
|
<Route exact path='/' element={<Home />} />
|
|
|
|
</Switch>
|
|
|
|
</Routes>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Router>
|
|
|
|
</Router>
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -581,7 +581,7 @@ import ReactDOM from 'react-dom'
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
BrowserRouter as Router,
|
|
|
|
BrowserRouter as Router,
|
|
|
|
Route,
|
|
|
|
Route,
|
|
|
|
Switch,
|
|
|
|
Routes,
|
|
|
|
NavLink,
|
|
|
|
NavLink,
|
|
|
|
} from 'react-router-dom'
|
|
|
|
} from 'react-router-dom'
|
|
|
|
|
|
|
|
|
|
|
@ -747,7 +747,7 @@ const Challenges = (props) => {
|
|
|
|
</li>
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
</ul>
|
|
|
|
<Switch>
|
|
|
|
<Routes>
|
|
|
|
<Route
|
|
|
|
<Route
|
|
|
|
exact
|
|
|
|
exact
|
|
|
|
path={'/challenges'}
|
|
|
|
path={'/challenges'}
|
|
|
@ -757,7 +757,7 @@ const Challenges = (props) => {
|
|
|
|
path={path}
|
|
|
|
path={path}
|
|
|
|
component={(props) => <Challenge challenge={challenge} />}
|
|
|
|
component={(props) => <Challenge challenge={challenge} />}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</Switch>
|
|
|
|
</Routes>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -785,13 +785,13 @@ class App extends Component {
|
|
|
|
<Router>
|
|
|
|
<Router>
|
|
|
|
<div className='App'>
|
|
|
|
<div className='App'>
|
|
|
|
<Navbar />
|
|
|
|
<Navbar />
|
|
|
|
<Switch>
|
|
|
|
<Routes>
|
|
|
|
<Route path='/about' component={About} />
|
|
|
|
<Route path='/about' element={<About />} />
|
|
|
|
<Route path='/contact' component={Contact} />
|
|
|
|
<Route path='/contact' element={<Contact />} />
|
|
|
|
<Route path='/challenges' component={Challenges} />
|
|
|
|
<Route path='/challenges' element={<Challenges />} />
|
|
|
|
<Route exact path='/' component={Home} />
|
|
|
|
<Route exact path='/' element={<Home />} />
|
|
|
|
<Route component={NotFound} />
|
|
|
|
<Route component={NotFound} />
|
|
|
|
</Switch>
|
|
|
|
</Routes>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Router>
|
|
|
|
</Router>
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -814,7 +814,7 @@ import ReactDOM from 'react-dom'
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
BrowserRouter as Router,
|
|
|
|
BrowserRouter as Router,
|
|
|
|
Route,
|
|
|
|
Route,
|
|
|
|
Switch,
|
|
|
|
Routes,
|
|
|
|
NavLink,
|
|
|
|
NavLink,
|
|
|
|
Redirect,
|
|
|
|
Redirect,
|
|
|
|
} from 'react-router-dom'
|
|
|
|
} from 'react-router-dom'
|
|
|
@ -981,7 +981,7 @@ const Challenges = (props) => {
|
|
|
|
</li>
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
</ul>
|
|
|
|
<Switch>
|
|
|
|
<Routes>
|
|
|
|
<Route
|
|
|
|
<Route
|
|
|
|
exact
|
|
|
|
exact
|
|
|
|
path={'/challenges'}
|
|
|
|
path={'/challenges'}
|
|
|
@ -991,7 +991,7 @@ const Challenges = (props) => {
|
|
|
|
path={path}
|
|
|
|
path={path}
|
|
|
|
component={(props) => <Challenge challenge={challenge} />}
|
|
|
|
component={(props) => <Challenge challenge={challenge} />}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</Switch>
|
|
|
|
</Routes>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1057,9 +1057,9 @@ class App extends Component {
|
|
|
|
<Router>
|
|
|
|
<Router>
|
|
|
|
<div className='App'>
|
|
|
|
<div className='App'>
|
|
|
|
<Navbar username={this.state.firstName} />
|
|
|
|
<Navbar username={this.state.firstName} />
|
|
|
|
<Switch>
|
|
|
|
<Routes>
|
|
|
|
<Route path='/about' component={About} />
|
|
|
|
<Route path='/about' element={<About />} />
|
|
|
|
<Route path='/contact' component={Contact} />
|
|
|
|
<Route path='/contact' element={<Contact />} />
|
|
|
|
<Route
|
|
|
|
<Route
|
|
|
|
path='/user/:username'
|
|
|
|
path='/user/:username'
|
|
|
|
component={(props) => (
|
|
|
|
component={(props) => (
|
|
|
@ -1090,9 +1090,9 @@ class App extends Component {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<Route exact path='/' component={Home} />
|
|
|
|
<Route exact path='/' element={<Home />} />
|
|
|
|
<Route component={NotFound} />
|
|
|
|
<Route component={NotFound} />
|
|
|
|
</Switch>
|
|
|
|
</Routes>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Router>
|
|
|
|
</Router>
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -1115,7 +1115,7 @@ import ReactDOM from 'react-dom'
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
BrowserRouter as Router,
|
|
|
|
BrowserRouter as Router,
|
|
|
|
Route,
|
|
|
|
Route,
|
|
|
|
Switch,
|
|
|
|
Routes,
|
|
|
|
NavLink,
|
|
|
|
NavLink,
|
|
|
|
Redirect,
|
|
|
|
Redirect,
|
|
|
|
Prompt,
|
|
|
|
Prompt,
|
|
|
@ -1283,7 +1283,7 @@ const Challenges = (props) => {
|
|
|
|
</li>
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
</ul>
|
|
|
|
<Switch>
|
|
|
|
<Routes>
|
|
|
|
<Route
|
|
|
|
<Route
|
|
|
|
exact
|
|
|
|
exact
|
|
|
|
path={'/challenges'}
|
|
|
|
path={'/challenges'}
|
|
|
@ -1293,7 +1293,7 @@ const Challenges = (props) => {
|
|
|
|
path={path}
|
|
|
|
path={path}
|
|
|
|
component={(props) => <Challenge challenge={challenge} />}
|
|
|
|
component={(props) => <Challenge challenge={challenge} />}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</Switch>
|
|
|
|
</Routes>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1361,9 +1361,9 @@ class App extends Component {
|
|
|
|
<Navbar username={this.state.firstName} />
|
|
|
|
<Navbar username={this.state.firstName} />
|
|
|
|
<Prompt message='Are you sure you want to leave?' />
|
|
|
|
<Prompt message='Are you sure you want to leave?' />
|
|
|
|
|
|
|
|
|
|
|
|
<Switch>
|
|
|
|
<Routes>
|
|
|
|
<Route path='/about' component={About} />
|
|
|
|
<Route path='/about' element={<About />} />
|
|
|
|
<Route path='/contact' component={Contact} />
|
|
|
|
<Route path='/contact' element={<Contact />} />
|
|
|
|
<Route
|
|
|
|
<Route
|
|
|
|
path='/user/:username'
|
|
|
|
path='/user/:username'
|
|
|
|
component={(props) => (
|
|
|
|
component={(props) => (
|
|
|
@ -1394,9 +1394,9 @@ class App extends Component {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<Route exact path='/' component={Home} />
|
|
|
|
<Route exact path='/' element={<Home />} />
|
|
|
|
<Route component={NotFound} />
|
|
|
|
<Route component={NotFound} />
|
|
|
|
</Switch>
|
|
|
|
</Routes>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Router>
|
|
|
|
</Router>
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -1415,7 +1415,7 @@ import ReactDOM from 'react-dom'
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
BrowserRouter as Router,
|
|
|
|
BrowserRouter as Router,
|
|
|
|
Route,
|
|
|
|
Route,
|
|
|
|
Switch,
|
|
|
|
Routes,
|
|
|
|
NavLink,
|
|
|
|
NavLink,
|
|
|
|
Redirect,
|
|
|
|
Redirect,
|
|
|
|
Prompt,
|
|
|
|
Prompt,
|
|
|
@ -1583,7 +1583,7 @@ const Challenges = (props) => {
|
|
|
|
</li>
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
</ul>
|
|
|
|
<Switch>
|
|
|
|
<Routes>
|
|
|
|
<Route
|
|
|
|
<Route
|
|
|
|
exact
|
|
|
|
exact
|
|
|
|
path={'/challenges'}
|
|
|
|
path={'/challenges'}
|
|
|
@ -1593,7 +1593,7 @@ const Challenges = (props) => {
|
|
|
|
path={path}
|
|
|
|
path={path}
|
|
|
|
component={(props) => <Challenge challenge={challenge} />}
|
|
|
|
component={(props) => <Challenge challenge={challenge} />}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</Switch>
|
|
|
|
</Routes>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1669,9 +1669,9 @@ class App extends Component {
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<Switch>
|
|
|
|
<Routes>
|
|
|
|
<Route path='/about' component={About} />
|
|
|
|
<Route path='/about' element={<About />} />
|
|
|
|
<Route path='/contact' component={Contact} />
|
|
|
|
<Route path='/contact' element={<Contact />} />
|
|
|
|
<Route
|
|
|
|
<Route
|
|
|
|
path='/user/:username'
|
|
|
|
path='/user/:username'
|
|
|
|
component={(props) => (
|
|
|
|
component={(props) => (
|
|
|
@ -1702,9 +1702,9 @@ class App extends Component {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<Route exact path='/' component={Home} />
|
|
|
|
<Route exact path='/' element={<Home />} />
|
|
|
|
<Route component={NotFound} />
|
|
|
|
<Route component={NotFound} />
|
|
|
|
</Switch>
|
|
|
|
</Routes>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Router>
|
|
|
|
</Router>
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -1721,7 +1721,7 @@ ReactDOM.render(<App />, rootElement)
|
|
|
|
|
|
|
|
|
|
|
|
1. What package do you use to implement routing in react?
|
|
|
|
1. What package do you use to implement routing in react?
|
|
|
|
2. What is the default export in react-router-dom?
|
|
|
|
2. What is the default export in react-router-dom?
|
|
|
|
3. What is the use of the following Components(Route, NavLink, Switch, Redirect, Prompt)
|
|
|
|
3. What is the use of the following Components(Route, NavLink, Routes, Redirect, Prompt)
|
|
|
|
|
|
|
|
|
|
|
|
## Exercises: Level 2
|
|
|
|
## Exercises: Level 2
|
|
|
|
|
|
|
|
|
|
|
|