JSFiddle - React, Tailwind, and code Playground
by Yury
HTML
<div id="app"></div>
CSS
body {
background: #20262E;0
padding: 20px;
font-family: Helvetica;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
}
div {
user-select: none;
}
button {
color: #eee;
background: #20262E;
padding: 10px 16px;
border: none;
border-radius: 3px;
cursor: pointer;
}
button.delay {
background: #20767E;
}
div > button + button {
margin-left: 24px;
}
React
const {useEffect, useState} = React;
const App = () => {
const [num, setNum] = useState(45);
const reset = () => setNum(0);
/* setInterval(() => {
setNum(num + 1);
}, 1000);
*/
return (
<React.Fragment>
<div onClick = {() => { setNum(num + 1)}} >
The current number is {num}.
</div>
<br/>
<button onClick = {() => { setNum(num + 1)}} >incr</button>
<button onClick = { () => {reset()} }>reset</button>
</React.Fragment>
);
}
const root = ReactDOM.createRoot(document.getElementById("app"));
root.render(<App />);