import React from 'react';
import './App.css';
import { useHistory, useParams, Route } from 'react-router-dom';
import artists from './ArtistList';
function ArtistProfile() {
const history = useHistory();
const {id} = useParams();
const selectedArtist= artists.find(artists =>
artists.id===id);
if(selectedArtist===undefined){
return <h1>error</h1>
}
const handleClick=()=>{
history.push("/");
}
return (
<div>
<button type="button" onClick={handleClick}>
Go home
</button>
<h1>{
selectedArtist.name}</h1>
<h2>Songs:</h2>
<ul>
{
selectedArtist.songs.map((song, index)=> <li key={index}>{song}</li>)}
</ul>
</div>
)
}
export default ArtistProfile();