File tree 1 file changed +10
-6
lines changed 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 1
1
import React , { Fragment , useEffect , useState } from 'react'
2
- import { BrowserRouter as Router , Route } from 'react-router-dom'
2
+ import { BrowserRouter as Router , Route , Switch } from 'react-router-dom'
3
3
4
4
import Header from './Header'
5
5
import Sidebar from './Sidebar'
@@ -47,11 +47,15 @@ const App = () => {
47
47
< div className = "content" >
48
48
< Sidebar />
49
49
< main className = "main" >
50
- < Route exact path = "/" component = { NewSnippet } />
51
- < Route exact path = "/recent" component = { RecentSnippets } />
52
- < Route exact path = "/:id([a-zA-Z0-9]+)" component = { Snippet } />
53
- < Route exact path = "/about" component = { About } />
54
- < Route exact path = "/sign-in" component = { SignIn } />
50
+ < Switch >
51
+ < Route exact path = "/" component = { NewSnippet } />
52
+ < Route exact path = "/about" component = { About } />
53
+ < Route exact path = "/recent" component = { RecentSnippets } />
54
+ < Route exact path = "/sign-in" component = { SignIn } />
55
+ // Switch renders the first matched route, so we need to keep this
56
+ // one last as the regexp below matches the paths of other pages
57
+ < Route exact path = "/:id([a-zA-Z0-9]+)" component = { Snippet } />
58
+ </ Switch >
55
59
</ main >
56
60
</ div >
57
61
</ Fragment >
You can’t perform that action at this time.
0 commit comments