mirror of
https://github.com/sr229/kuru-kuru.git
synced 2024-09-20 04:10:33 +00:00
refactor: Refactor CounterCard component to use BigInt for globalCount
Refactor CounterCard component to use BigInt for globalCount state and parse globalCount as an integer
This commit is contained in:
parent
6b05b7d6a9
commit
f2abd5110c
1 changed files with 4 additions and 2 deletions
|
@ -45,7 +45,9 @@ export function animateMascot() {
|
||||||
|
|
||||||
export default function Counter(props: SharedProps) {
|
export default function Counter(props: SharedProps) {
|
||||||
const [count, setCount] = useState(0);
|
const [count, setCount] = useState(0);
|
||||||
const [globalCount, setGlobalCount] = useState(props.globalCount ?? 0);
|
const [globalCount, setGlobalCount] = useState(
|
||||||
|
BigInt(props.globalCount ?? 0),
|
||||||
|
);
|
||||||
const [internalCount, setInternalCount] = useState(0);
|
const [internalCount, setInternalCount] = useState(0);
|
||||||
const [timer, setTimer] = useState(0);
|
const [timer, setTimer] = useState(0);
|
||||||
|
|
||||||
|
@ -104,7 +106,7 @@ export default function Counter(props: SharedProps) {
|
||||||
es.addEventListener("message", (e) => {
|
es.addEventListener("message", (e) => {
|
||||||
console.log(`[${new Date()}] Received global count: ${e.data}`);
|
console.log(`[${new Date()}] Received global count: ${e.data}`);
|
||||||
const data = JSON.parse(e.data);
|
const data = JSON.parse(e.data);
|
||||||
setGlobalCount(parseInt(data.globalCount));
|
setGlobalCount(BigInt(parseInt(data.globalCount)));
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Reconnect backoff logic could be improved
|
// TODO: Reconnect backoff logic could be improved
|
||||||
|
|
Loading…
Reference in a new issue