perf(opt): implement memo, useCallback and useMemo for performance optimization

This commit is contained in:
2026-04-27 14:41:21 +02:00
parent e102c83344
commit ef06f22edc
3 changed files with 16 additions and 10 deletions
+7 -2
View File
@@ -1,4 +1,4 @@
import { useState } from "react"
import { useMemo, useState } from "react"
import { TaskItem } from "./components/TaskItem";
import { useTasks } from "./hooks/useTasks";
@@ -7,9 +7,14 @@ function App() {
const [inputValue, setInputValue] = useState<string>('');
const { tasks, addTask, deleteTask, toggleTask } = useTasks();
const completedCount = useMemo(() => {
console.log("Counting tasks...");
return tasks.filter(t => t.completed).length;
}, [tasks]);
return (
<div className="container">
<h1>SmartX Task Manager</h1>
<h1>SmartX Task Manager {completedCount}</h1>
<div className="input-group">
<input