Skip to content

Commit fc383d3

Browse files
committed
created a counter with a hook useState
1 parent 583a167 commit fc383d3

File tree

2 files changed

+16
-77
lines changed

2 files changed

+16
-77
lines changed

README.md

-74
This file was deleted.

src/App.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
1+
import React from 'react';
12
import './index.scss';
23

34
function App() {
5+
6+
const [count, setCount] = React.useState(0);
7+
8+
const onClickPlus = () => {
9+
setCount(count + 1);
10+
}
11+
12+
const onClickMinus = () => {
13+
setCount(count - 1);
14+
}
15+
416
return (
517
<div className="App">
618
<div>
719
<h2>Счетчик:</h2>
8-
<h1>0</h1>
9-
<button className="minus">- Минус</button>
10-
<button className="plus">Плюс +</button>
20+
<h1>{count}</h1>
21+
<button onClick={onClickMinus} className="minus">- Минус</button>
22+
<button onClick={onClickPlus} className="plus">Плюс +</button>
1123
</div>
1224
</div>
1325
);
1426
}
1527

1628
export default App;
29+

0 commit comments

Comments
 (0)