From 8ebfcdb0899cf838ad1b3a99dda5fa2a9d5b854b Mon Sep 17 00:00:00 2001 From: catloversg <152669316+catloversg@users.noreply.github.com> Date: Sat, 11 May 2024 08:55:45 +0700 Subject: [PATCH] MISC: Fix bugs in useRerender hook and ns.moveTail (#1263) --- src/ui/React/LogBoxManager.tsx | 1 + src/ui/React/hooks.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ui/React/LogBoxManager.tsx b/src/ui/React/LogBoxManager.tsx index 530b6ce20..ca5773f41 100644 --- a/src/ui/React/LogBoxManager.tsx +++ b/src/ui/React/LogBoxManager.tsx @@ -58,6 +58,7 @@ export class LogBoxProperties { this.x = x; this.y = y; this.updateDOM(); + this.rerender(); } setSize(width: number, height: number): void { diff --git a/src/ui/React/hooks.ts b/src/ui/React/hooks.ts index ef1ba37e2..c6baf2500 100644 --- a/src/ui/React/hooks.ts +++ b/src/ui/React/hooks.ts @@ -4,9 +4,9 @@ import { useCallback, useEffect, useState } from "react"; * @param autoRerenderTime: Optional. If provided and nonzero, used as the ms interval to automatically call the rerender function. */ export function useRerender(autoRerenderTime?: number) { - const [__, setRerender] = useState(false); + const [__, setRerender] = useState(0); - const rerender = useCallback(() => setRerender((old) => !old), []); + const rerender = useCallback(() => setRerender((currentValue) => currentValue + 1), []); useEffect(() => { if (!autoRerenderTime) return;