Skip to content

Commit 4f8d8ac

Browse files
authored
Merge pull request #4 from nomspace/3-update-routing
#3 Hashrouting + simplifying routes
2 parents 279fbb5 + 58f23d6 commit 4f8d8ac

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

src/App.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React from "react";
22
import { Container } from "theme-ui";
3-
import { Redirect, Route, Switch } from "react-router-dom";
3+
import { Route, Switch } from "react-router-dom";
44
import { Search } from "src/pages/Search";
5-
import { Stats } from "src/pages/Stats";
65
import { SearchDetail } from "src/pages/SearchDetail";
76
import { Reserve } from "src/pages/Reserve";
87
import { Extend } from "src/pages/Extend";
@@ -23,24 +22,18 @@ const App: React.FC = () => {
2322
<Header />
2423
<Switch>
2524
<Route exact path="/">
26-
<Redirect to="/search" />
27-
</Route>
28-
<Route exact path="/search">
2925
<Search />
3026
</Route>
31-
<Route exact path="/stats">
32-
<Stats />
33-
</Route>
34-
<Route exact path="/search/:name">
27+
<Route exact path="/:name">
3528
<SearchDetail />
3629
</Route>
37-
<Route exact path="/search/:name/reserve">
30+
<Route exact path="/:name/reserve">
3831
<Reserve />
3932
</Route>
40-
<Route exact path="/search/:name/request">
33+
<Route exact path="/:name/request">
4134
<Request />
4235
</Route>
43-
<Route exact path="/search/:name/extend">
36+
<Route exact path="/:name/extend">
4437
<Extend />
4538
</Route>
4639
</Switch>

src/components/SearchBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const SearchBar: React.FC<IProps> = ({ size }) => {
5454
onSubmit={(e) => {
5555
const searchTerm = searchInput?.current.value;
5656
if (searchTerm && searchTerm !== "") {
57-
history.push(`/search/${searchTerm}`);
57+
history.push(`/${searchTerm}`);
5858
}
5959
e.preventDefault();
6060
}}

src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Provider } from "react-redux";
1212
import store from "src/state";
1313
import theme from "src/theme";
1414
import { ThemeProvider } from "theme-ui";
15-
import { HashRouter as Router } from "react-router-dom";
15+
import { BrowserRouter as Router } from "react-router-dom";
1616

1717
import App from "./App";
1818
import * as serviceWorker from "./serviceWorker";

0 commit comments

Comments
 (0)