-
-
Save codecademydev/ac844f50d05febad4f524ec3e0097fe1 to your computer and use it in GitHub Desktop.
Codecademy export
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
import React from 'react'; | |
import GroceryItem from './GroceryItem'; | |
function App() { | |
return ( | |
<div> | |
<GroceryItem item="Eggs" /> | |
<GroceryItem item="Banana" /> | |
<GroceryItem item="Strawberry" /> | |
<GroceryItem item="Bread" /> | |
</div> | |
); | |
} | |
export default App |
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
import React from 'react'; | |
function GroceryItem(props) { | |
function handleClick(item) { | |
alert(`The ${item} has been added to the cart!`); | |
} | |
return ( | |
<button onClick={() => handleClick(props.item)}> | |
{props.item} | |
</button> | |
); | |
}; | |
export default GroceryItem; |
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 name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="stylesheet" href="style.css"> | |
</head> | |
<body> | |
<main id="app"> | |
</main> | |
<script src="https://content.codecademy.com/courses/React/react-18-course-bundle.min.js"></script> | |
<script src="/index.compiled.js"></script> | |
</body> | |
</html> |
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
import React from 'react'; | |
import ReactDOM from 'react-dom/client'; | |
import App from './App'; | |
ReactDOM.createRoot( | |
document.getElementById('app') | |
).render(<App />); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment