Exercise 10 - React Hook - UseState
Exercise 10 - React Hook - UseState
Using the React Hook such as: State Hook in your app.
1
info:'Neymar da Silva Santos Júnior (born 5 February 1992), known as
Neymar, is a Brazilian professional footballer who plays as a forward for
Ligue 1 club Paris Saint-Germain and the Brazil national team. He is
considered a versatile player, being able to play as either a central
striker, second striker, winger or occasionally as an attacking midfielder.
A prolific goalscorer and renowned playmaker, he is regarded as one of the
best players in the world. Neymar has scored at least 100 goals for three
different clubs, making him one of three players to achieve this'
},
{
id: 5,
name: 'Kane',
club: 'Tottenham',
img:'assets/images/kane.jpg',
info: 'Harry Edward Kane MBE (born 28 July 1993) is an English
professional footballer who plays as a striker for Premier League club
Tottenham Hotspur and captains the England national team. Regarded as one of
the best strikers in the world, Kane is known for his prolific goalscoring
record and ability to link play.[4][5] He ranks as Tottenham second-highest
all-time top goalscorer and the third-highest Premier League all-time top
goalscorer'
},
{
id: 6,
name: 'Haaland',
club: 'Manchester City',
img: 'assets/images/haaland.jpg',
info: 'Erling Braut Haaland (né Håland; born 21 July 2000) is a
Norwegian professional footballer who plays as a striker for Premier League
club Manchester City and the Norway national team. Considered one of the
best players in the world, he is known for his athleticism, speed and
finishing.'
}
2
Add some styles to App.css for modal as follow:
.overlay {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 500ms;
visibility: hidden;
opacity: 0;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.popup {
margin: 70px auto;
padding: 5px;
background: #fff;
border-radius: 5px;
width: 30%;
position: relative;
transition: all 5s ease-in-out;
}
.popup img{ width: 100%;}
.popup h2 {
margin-top: 0;
color: #333;
font-family: Tahoma, Arial, sans-serif;
3
}
.popup .close {
position: absolute;
top: 20px;
right: 30px;
transition: all 200ms;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #333;
}
.popup .close:hover {color: #06D85F;}
.popup .content {
max-height: 30%;
overflow: auto;
}
<button onClick={()=>{setPlayer(player)}}>
<a href='#popup1' id='openPopUp'>Detail</a>
</button>
Screen display
4
Conclusions
In this exercise you learnt how to use State Hook in your app.