Skip to content

Commit

Permalink
fix(Display): Removed temporary counter
Browse files Browse the repository at this point in the history
  • Loading branch information
nachovigilante committed Jul 29, 2022
1 parent a781e1d commit 0cf0883
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/components/Display.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ export const Display = ({
}: DisplayType) => {
const [digits, setDigits] = useState([]);

const [actualValue, setActualValue] = useState(value) as [any, any];

useEffect(() => {
setTimeout(() => {
console.log(actualValue);
setActualValue((v: any) => parseInt(v) + 1);
}, 500);
}, [actualValue]);

const style = {
display: "flex",
flexDirection: "row",
Expand All @@ -52,20 +43,20 @@ export const Display = ({
} as React.CSSProperties;

useEffect(() => {
let newDigits = actualValue && actualValue.toString().split("");
let newDigits = value && value.toString().split("");

if (!actualValue || count < actualValue.toString().length) {
if (!value || count < value.toString().length) {
newDigits = null;
}

if (actualValue && count > actualValue.toString().length) {
for (let i = 0; i < count - actualValue.toString().length; i++) {
if (value && count > value.toString().length) {
for (let i = 0; i < count - value.toString().length; i++) {
newDigits.unshift("0");
}
}

setDigits(newDigits);
}, [count, actualValue]);
}, [count, value]);

return (
<div className="display" style={displayStyle}>
Expand Down

0 comments on commit 0cf0883

Please sign in to comment.