perf: replace Array#map Array#filter chain w/ Array#reduce (#1203)

This commit is contained in:
Sukka
2024-06-15 12:22:33 +08:00
committed by GitHub
parent a0f9fb90ee
commit 0332415ac9
3 changed files with 58 additions and 36 deletions

View File

@@ -24,11 +24,11 @@ const LogPage = () => {
const [match, setMatch] = useState(() => (_: string) => true);
const filterLogs = useMemo(() => {
return logData
.filter((data) =>
logState === "all" ? true : data.type.includes(logState)
)
.filter((data) => match(data.payload));
return logData.filter(
(data) =>
(logState === "all" ? true : data.type.includes(logState)) &&
match(data.payload)
);
}, [logData, logState, match]);
return (