Created
February 10, 2023 14:45
-
-
Save BalachandraTejas/62088ee4600f9a78456a74423a6a5425 to your computer and use it in GitHub Desktop.
React JS page in html: Components
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>React JS</title> | |
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script> | |
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script> | |
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> | |
</head> | |
<body> | |
<div id="root"></div> | |
<script type="text/babel"> | |
function Header() { | |
return <h1>Pets</h1> | |
} | |
const pets = [ | |
{ | |
id: 1, | |
image: "https://images.unsplash.com/photo-1554456854-55a089fd4cb2?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2340&q=80", | |
name: "Rocky" | |
}, | |
{ | |
id: 2, | |
image: "https://images.unsplash.com/photo-1561037404-61cd46aa615b?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2340&q=80", | |
name: "Blaze" | |
}, | |
{ | |
id: 3, | |
image: "https://images.unsplash.com/photo-1576201836106-db1758fd1c97?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2340&q=80", | |
name: "Happy" | |
} | |
] | |
function Body() { | |
return ( | |
<ul> | |
{pets.map(pet => ( | |
<li key={pet.id}> | |
<img src={pet.image} | |
alt={pet.name} | |
height="200"/> | |
<p>{pet.name}</p> | |
</li> | |
))} | |
</ul> | |
) | |
} | |
function Footer() { | |
return <h3>-- We ❤️ Pets --</h3> | |
} | |
function App() { | |
return ( | |
<> | |
<Header /> | |
<Body /> | |
<Footer /> | |
</> | |
) | |
} | |
ReactDOM.render( | |
<App />, | |
document.getElementById('root') | |
); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment