startit/react_test/tutorial/index.html

47 lines
1.3 KiB
HTML
Raw Normal View History

2024-09-05 11:25:53 +02:00
<html>
<body>
<div id="app"></div>
<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 src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script type="text/jsx">
const domNode = document.getElementById('app');
function createTitle(title) {
if (title) {
return title;
} else {
return 'Default title';
}
}
function Header({ title }) {
return <h1>{title ? title : 'Default Title'}</h1>;
}
function HomePage() {
const names = ['Ada Lovlace', 'Grace Hopper', 'Margaret Hamilton'];
function handleClick(){
console.log("increment like count")
}
return( <div>
<Header title="Develop. Preview. Ship." />
<ul>
{names.map((name) => (
<li key={name}>{name}</li>
))}
</ul>
<button onClick={handleClick}>Like</button>
</div>
);
}
const root = ReactDOM.createRoot(domNode);
2024-09-06 14:34:17 +02:00
root.render(<HomePage />);
2024-09-05 11:25:53 +02:00
</script>
</body>
2024-09-05 11:25:53 +02:00
</html>