Skip to content

Commit 2954242

Browse files
Adding the function restaurant and buttonAdd to increase the number of pizzas when the button Add is clicked
1 parent d88461e commit 2954242

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
const Restaurant = () => {
2-
const pizzas = 0;
1+
import { useState } from "react";
2+
3+
function Restaurant() {
4+
const [pizzas, setPizzas] = useState(0);
5+
6+
function buttonAdd() {
7+
setPizzas(pizzas + 1);
8+
}
9+
310
return (
411
<section className="restaurant">
512
<h3 className="restaurant__heading">Restaurant Orders</h3>
613
<ul className="restaurant__list">
714
<li className="restaurant__item">
815
Pizzas: {pizzas}{" "}
9-
<button className="button restaurant__button" onClick={Restaurant}>
16+
<button className="button restaurant__button" onClick={buttonAdd}>
1017
Add
1118
</button>
1219
</li>
1320
</ul>
1421
</section>
1522
);
16-
};
23+
}
1724

1825
export default Restaurant;

0 commit comments

Comments
 (0)