-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09defe2
commit a8d2f76
Showing
4 changed files
with
45 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,11 @@ | |
--> | ||
<title>React App</title> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" | ||
/> | ||
|
||
</head> | ||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,51 @@ | ||
import { useParams, Navigate } from "react-router-dom" | ||
import { useMemo } from "react"; | ||
import { useParams, Navigate, useNavigate } from "react-router-dom" | ||
import getHeroesById from "../../selectors/getHerosById"; | ||
|
||
export const HeroScreen = () => { | ||
|
||
const navigate = useNavigate(); | ||
const { heroeId } = useParams(); | ||
const hero = getHeroesById( heroeId ); | ||
const hero = useMemo(() => getHeroesById( heroeId ), [heroeId]); | ||
|
||
if( !hero ) | ||
return <Navigate to='/' /> | ||
|
||
|
||
const imgPath = `/assets/${hero.id}.jpg`; | ||
const { superhero, alter_ego, id, publisher, first_appearance, characters } = hero; | ||
|
||
|
||
const handleReturn = () => { | ||
navigate(-1); | ||
} | ||
|
||
return ( | ||
<div> | ||
<h1>HeroScreen</h1> | ||
<p> | ||
{hero.superhero} | ||
</p> | ||
<div className="row mt-5"> | ||
<div className="col-4"> | ||
<img src={imgPath} alt={superhero} className='img-thumbnail animate__animated animate__fadeInLeft' /> | ||
</div> | ||
|
||
<div className="col-8 animate__animated animate__fadeIn"> | ||
<h3>{ superhero }</h3> | ||
<ul className="list-group"> | ||
<li className="list-group-item"><b>Alter ego: </b>{alter_ego}</li> | ||
<li className="list-group-item"><b>Publisher: </b>{publisher}</li> | ||
<li className="list-group-item"><b>First Appearance: </b>{first_appearance}</li> | ||
</ul> | ||
|
||
<h5 className="mt-3">Characters</h5> | ||
<p>{ characters }</p> | ||
|
||
<button | ||
className="btn btn-outline-info" | ||
onClick={handleReturn} | ||
> | ||
Regresar | ||
</button> | ||
|
||
</div> | ||
|
||
</div> | ||
) | ||
} |