Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

part11-7 OK #12

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { BrowserRouter as Routes, Route, useMatch } from "react-router-dom";
import { Routes, Route, useMatch } from "react-router-dom";
import { useApi } from "./useApi";
import LoadingSpinner from "./LoadingSpinner";
import ErrorMessage from "./ErrorMessage";
Expand All @@ -14,6 +14,8 @@ const mapResults = ({ results }) =>
}));

const App = () => {
let next = null;
let previous = null;
const match = useMatch("/pokemon/:name");
const {
data: pokemonList,
Expand All @@ -28,9 +30,6 @@ const App = () => {
return <ErrorMessage error={error} />;
}

let next = null;
let previous = null;

if (match && match.params) {
const pokemonId = pokemonList.find(
({ name }) => name === match.params.name
Expand Down
2 changes: 1 addition & 1 deletion src/PokemonPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const PokemonPage = ({ previous, next }) => {
<div className="links">
{previous && <Link to={`/pokemon/${previous.name}`}>Previous</Link>}
<Link to="/">Home</Link>
{next && <Link to={`/pokemon/${previous.name}`}>Next</Link>}
{next && <Link to={`/pokemon/${next.name}`}>Next</Link>}
</div>
<div className={`pokemon-page pokemon-type-${type.name}`}>
<div
Expand Down