Skip to content

Commit

Permalink
fix: routing fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lbratkovskaya committed Mar 8, 2021
1 parent dafb94d commit 910ecf7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 3 additions & 5 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import {
BrowserRouter,
Redirect,
Route,
Switch,
} from 'react-router-dom';
Expand Down Expand Up @@ -37,13 +36,12 @@ const App: React.FC<rootProps> = (props: rootProps) => (
</Button>
<BrowserRouter>
<Switch>
<Route path="/countries">
<MainPage />
</Route>
<Route path="/country/:countryId">
<CountryPage />
</Route>
<Redirect path="/" to="/countries" />
<Route path="/">
<MainPage />
</Route>
</Switch>
</BrowserRouter>
</div>
Expand Down
6 changes: 4 additions & 2 deletions src/components/CountryPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import {
import {
useParams,
} from 'react-router-dom';
import { rootProps } from '../../store/rootConnector';
import rootConnector, {
rootProps,
} from '../../store/rootConnector';
import { URLParamTypes } from '../../types';

const CountryPage: React.FC<rootProps> = () => {
Expand All @@ -18,4 +20,4 @@ const CountryPage: React.FC<rootProps> = () => {
return (<div title={t(`${countryId}.name`)}>{t(`${countryId}.name`)}</div>);
};

export default CountryPage;
export default rootConnector(CountryPage);
2 changes: 1 addition & 1 deletion src/components/ImagesGrid/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const ImagesGrid: React.FC<rootProps> = (props: rootProps) => {
<GridList className={classes.gridList} cols={2.5}>
{countries.map((country) => (
<GridListTile key={country.pictureURL}>
<Link to={`country/${country.id}`}>
<Link to={`/country/${country.id}`}>
<img
src={country.pictureURL}
alt={t(`${country.id}.name`)}
Expand Down

0 comments on commit 910ecf7

Please sign in to comment.