MISC: Fix bugs in useRerender hook and ns.moveTail (#1263)

This commit is contained in:
catloversg 2024-05-11 08:55:45 +07:00 committed by GitHub
parent 19984a6f22
commit 8ebfcdb089
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

@ -58,6 +58,7 @@ export class LogBoxProperties {
this.x = x;
this.y = y;
this.updateDOM();
this.rerender();
}
setSize(width: number, height: number): void {

@ -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;