-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.jsx
More file actions
34 lines (28 loc) · 829 Bytes
/
app.jsx
File metadata and controls
34 lines (28 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import Button from "./components/Button";
import {useEffect, useState} from "react";
function App() {
const [count, setCount] = useState(0);
const increment = () => {
setCount(count + 1);
};
const decrement = () => {
setCount(count - 1);
};
const reset = () => {
setCount(0);
};
useEffect(() => {
console.log("Count value changed:", count);
setCount(count+1);
},[count])
return (
<div style={{textAlign: "center", marginTop: "50px"}}>
<h1>Simple Counter App</h1>
<h2>count:{count}</h2>
<Button label="Increment" onClick={increment} />
<Button label="Decrement" onClick={decrement} />
<Button label="Reset" onClick={reset} />
</div>
);
}
export default App;