Skip to content

Instantly share code, notes, and snippets.

@hatemhosny
Last active September 3, 2022 09:31
Show Gist options
  • Save hatemhosny/f01deb828a42f363502fbae7964d48e9 to your computer and use it in GitHub Desktop.
Save hatemhosny/f01deb828a42f363502fbae7964d48e9 to your computer and use it in GitHub Desktop.
React demo
<div id="app">Loading...</div>
import React, { useState } from "react";
import ReactDOM from "react-dom";
function App(props) {
const [count, setCount] = useState(0);
return (
<div class="container">
<h1>Hello, {props.name}!</h1>
<img src="https://livecodes.io/livecodes/assets/templates/react.svg" className="logo" />
<p>You clicked {count} times.</p>
<button onClick={() => setCount(count + 1)}>Click me</button>
</div>
);
}
ReactDOM.render(<App name="React" />, document.querySelector("#app"));
.container,
.container button {
text-align: center;
font: 1em sans-serif;
}
.logo {
width: 150px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment