Back to tasksGet help with live coding in real time with Sobes Copilot
Junior — Senior
26
Проведение ревью компонентов App и Todo в React‑приложении
Task condition
Необходимо выполнить обзор кода файлов App.tsx и Todo.tsx.
// App.tsx
import React, { useState } from "react";
import "./index.css";
import Todo from "./Todo";
export const tasks = [
{
name: "clear",
id: "1",
imagesrc: "https://avatars.githubusercontent.com/u/45297354?v=4",
},
{
name: "buy",
id: "2",
imagesrc: "https://avatars.githubusercontent.com/u/6751787?v=4",
},
{ name: "change", id: "3" },
{ name: "code", id: "4" },
{ name: "test", id: "5" },
];
export default function App() {
const [search, setSearch] = React.useState("");
return (
<div className="App">
<input
type="text"
value={search}
onChange={(e) => setSearch(e.target.value)}
/>
{tasks
.filter((item) => item.name.includes(search))
.map((el) => (
<Todo todo={el} />
))}
</div>
);
}
// Todo.tsx
import "./todo.css";
const Todo = ({ todo }: any) => (
<div className="todo">
<img
style={{ width: 40, borderRadius: 40 }}
src={todo.imagesrc}
alt={todo.name}
/>
{todo.name}
</div>
);
export default Todo;