Skip to content

Commit

Permalink
solutin2
Browse files Browse the repository at this point in the history
  • Loading branch information
RuslanMudryi committed Dec 16, 2024
1 parent 5a7e5d1 commit 0ab0d88
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
11 changes: 6 additions & 5 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ export const App: React.FC = () => {
const [selectedTodo, setSelectedTodo] = useState<Todo | null>(null);

useEffect(() => {
getTodos().then(data => {
setTodosFromServer(data);
setIsDataLoaded(true);
});
}, [status]);
getTodos()
.then(data => {
setTodosFromServer(data);
})
.finally(() => setIsDataLoaded(true));
}, []);

const filteredTodos = todosFromServer
.filter(todo => {
Expand Down
10 changes: 5 additions & 5 deletions src/components/TodoFilter/TodoFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
type Props = {
setStatus: (status: () => string) => void;
setQuery: (status: () => string) => void;
setStatus: (status: string) => void;
setQuery: (status: string) => void;
query: string;
};

export const TodoFilter: React.FC<Props> = ({ query, setStatus, setQuery }) => {
const handlerOnChangeStatus = (
event: React.ChangeEvent<HTMLSelectElement>,
): void => {
setStatus(() => event.target.value);
setStatus(event.target.value);
};

const handlerOnChangeQuery = (
event: React.ChangeEvent<HTMLInputElement>,
): void => {
setQuery(() => event.target.value);
setQuery(event.target.value);
};

return (
Expand Down Expand Up @@ -49,7 +49,7 @@ export const TodoFilter: React.FC<Props> = ({ query, setStatus, setQuery }) => {
type="button"
className="delete"
onClick={() => {
setQuery(() => '');
setQuery('');
}}
/>
</span>
Expand Down

0 comments on commit 0ab0d88

Please sign in to comment.