Skip to content

Commit

Permalink
Merge pull request #160 from xsnippet/fix-routing
Browse files Browse the repository at this point in the history
Fix routing
  • Loading branch information
malor authored Jun 7, 2021
2 parents a937493 + eaadef2 commit 0fe1894
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/components/App.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Fragment, useEffect, useState } from 'react'
import { BrowserRouter as Router, Route } from 'react-router-dom'
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'

import Header from './Header'
import Sidebar from './Sidebar'
Expand Down Expand Up @@ -47,11 +47,15 @@ const App = () => {
<div className="content">
<Sidebar />
<main className="main">
<Route exact path="/" component={NewSnippet} />
<Route exact path="/recent" component={RecentSnippets} />
<Route exact path="/:id([a-zA-Z0-9]+)" component={Snippet} />
<Route exact path="/about" component={About} />
<Route exact path="/sign-in" component={SignIn} />
<Switch>
<Route exact path="/" component={NewSnippet} />
<Route exact path="/about" component={About} />
<Route exact path="/recent" component={RecentSnippets} />
<Route exact path="/sign-in" component={SignIn} />
// Switch renders the first matched route, so we need to keep this
// one last as the regexp below matches the paths of other pages
<Route exact path="/:id([a-zA-Z0-9]+)" component={Snippet} />
</Switch>
</main>
</div>
</Fragment>
Expand Down

0 comments on commit 0fe1894

Please sign in to comment.