litt react og funksjoner på slutten av dagen
This commit is contained in:
parent
d3f21427f0
commit
492f0ef432
|
@ -1,22 +1,47 @@
|
|||
<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 Header() {
|
||||
return (<h1>Develop. Preview. Ship.</h1>)
|
||||
<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() {
|
||||
return <div>
|
||||
<Header />
|
||||
</div>;
|
||||
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);
|
||||
root.render(<HomePage />);
|
||||
</script>
|
||||
</body>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in a new issue