frontends/react/index.html

41 lines
1.4 KiB
HTML

<html>
<body>
<div id="app"></div>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script src="https://unpkg.com/react@18/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
<script type="text/jsx">
const app = document.getElementById('app');
const blurb_data = {
title: "Fart Man Comes To Town!",
blurb: "Will this controversial figure finally cause the downfall of the town? Sally Smith from town center says that she can already smell trouble brewing but other members of the town believe the imminent winds of change will revitalize the towns central business district."
};
function Blurb({ title, blurb }) {
return (<div>
<h1>{ title }</h1>
<p>{ blurb }</p>
<a href="#">Read more...</a>
</div>);
}
function HomePage() {
const [blurbs, setBlurbs] = React.useState([ blurb_data ])
function addBlurb() {
setBlurbs(blurbs.concat([blurb_data]));
}
return (<>
{blurbs.map((blurb, i) => (
<Blurb key={i} {...blurb} />
))}
<br />
<button onClick={addBlurb}>Load More</button>
</>);
}
const root = ReactDOM.createRoot(app);
root.render(<HomePage />);
</script>
</body>
</html>