perf: memo

This commit is contained in:
cha0s 2024-10-02 15:12:14 -05:00
parent 0639c825a9
commit 066abec937

View File

@ -1,4 +1,4 @@
import {useCallback, useState} from 'react'; import {memo, useCallback, useState} from 'react';
import {useEcsTick} from '@/react/context/ecs.js'; import {useEcsTick} from '@/react/context/ecs.js';
@ -19,6 +19,8 @@ export function Time({hour, minute}) {
); );
} }
const MemoTime = memo(Time);
function ConnectedTime() { function ConnectedTime() {
const [hour, setHour] = useState(-1); const [hour, setHour] = useState(-1);
const [minute, setMinute] = useState(0); const [minute, setMinute] = useState(0);
@ -35,7 +37,7 @@ function ConnectedTime() {
if (-1 === hour) { if (-1 === hour) {
return false; return false;
} }
return <Time hour={hour} minute={minute} />; return <MemoTime hour={hour} minute={minute} />;
} }
export default ConnectedTime; export default ConnectedTime;