Skip to content

Commit

Permalink
Do not call decrement func when button disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswilty committed Mar 14, 2024
1 parent 9058240 commit 1584d5a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ function App() {
const downIsDisabled = count <= 0;

const increment = () => setCount((prev) => prev + 1);
const decrement = () => setCount((prev) => Math.max(prev - 1, 0));
const decrement = () => {
!downIsDisabled && setCount((prev) => Math.max(prev - 1, 0));
};

return (
<main>
Expand Down

0 comments on commit 1584d5a

Please sign in to comment.