refactor: Move logging to proper conditional block

This commit is contained in:
Ayane Satomi 2023-10-22 05:47:48 +00:00
parent be94406c49
commit 6b05b7d6a9

View file

@ -74,10 +74,6 @@ export default function Counter(props: SharedProps) {
clearTimeout(timer);
setTimer(setTimeout(() => {
console.info(
`[${new Date()}] Updating global count: ${internalCount + 1}`,
);
// guard against numbers that are beyond MAX_SAFE_INTEGER.
if (internalCount === Number.MAX_SAFE_INTEGER) {
console.warn(
@ -90,6 +86,9 @@ export default function Counter(props: SharedProps) {
window.location.href,
JSON.stringify({ data: internalCount + 1 }),
);
console.info(
`[${new Date()}] Updating global count: ${internalCount + 1}`,
);
setInternalCount(0);
}
}, 5000));