Skip to content

Commit

Permalink
Latest
Browse files Browse the repository at this point in the history
  • Loading branch information
Stevemoretz committed Apr 8, 2022
1 parent b210253 commit 0eb8066
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/SlidingCounter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,17 @@ export default function SlidingCounter({

useEffect(() => {
if (onValueChanged) {
onValueChanged(count);
if (count !== value) {
onValueChanged(count);
}
}
}, [count]);

useEffect(() => {
setCount(applyLimits(value));
const result = applyLimits(value);
if (result !== count) {
setCount(result);
}
}, [value]);

const incrementCount = useCallback(() => {
Expand Down

0 comments on commit 0eb8066

Please sign in to comment.