-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update React components and add like functionality to pure-rea…
…ct.html
- Loading branch information
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<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 app = document.getElementById("app") | ||
|
||
function Header({ title }) { | ||
return <h1>{title ? title : "Default title"}</h1> | ||
} | ||
|
||
function HomePage() { | ||
const names = ["pure-react"] | ||
|
||
|
||
return ( | ||
<div> | ||
<Header title="Develop. Preview. Ship." /> | ||
<ul> | ||
{names.map((name) => { | ||
let href = `learn/${name}.html`; | ||
return (<li key={name}><a href={href}>{name}</a></li>); | ||
})} | ||
</ul> | ||
</div> | ||
) | ||
} | ||
|
||
const root = ReactDOM.createRoot(app); | ||
root.render(<HomePage />); | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<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 app = document.getElementById("app") | ||
|
||
function Header({ title }) { | ||
return <h1>{title ? title : "Default title"}</h1> | ||
} | ||
|
||
function HomePage() { | ||
const names = ["Ada Lovelace", "Grace Hopper", "Margaret Hamilton"] | ||
|
||
const [likes, setLikes] = React.useState(0) | ||
|
||
function handleClick() { | ||
setLikes(likes + 1) | ||
} | ||
|
||
return ( | ||
<div> | ||
<Header title="Develop. Preview. Ship." /> | ||
<ul> | ||
{names.map((name) => ( | ||
<li key={name}>{name}</li> | ||
))} | ||
</ul> | ||
|
||
<button onClick={handleClick}>Like ({likes})</button> | ||
</div> | ||
) | ||
} | ||
|
||
const root = ReactDOM.createRoot(app); | ||
root.render(<HomePage />); | ||
</script> | ||
</body> | ||
|
||
</html> |