Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add task solution #1527

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

BohdanDymydiuk
Copy link

@BohdanDymydiuk BohdanDymydiuk commented Nov 30, 2024

src/App.tsx Outdated

export const App: React.FC = () => {
// #region variables

const [value, setValue] = useState<string>('');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's redundant to specify types for primitives

Suggested change
const [value, setValue] = useState<string>('');
const [value, setValue] = useState('');

src/App.tsx Outdated
Comment on lines 80 to 86
useEffect(() => {
if (completedTodos.length > 0 && completedTodos.length === todos.length) {
setAllCompleted(true);
} else if (allCompleted) {
setAllCompleted(false);
}
}, [allCompleted, completedTodos, todos.length]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's can just be the variable

  const isAllCompleted = completedTodos.length > 0 && completedTodos.length === todos.length

src/App.tsx Outdated
const [error, setError] = useState<string>('');
const [allCompleted, setAllCompleted] = useState<boolean>(false);
const [editedInputById, setEditedInputById] = useState<number>(-1);
const [key, setKey] = useState<string>('');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need a separate state for the key, feel free to ask for some help in the chat

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you think so?

src/App.tsx Outdated
Comment on lines 58 to 60
const [idsOfRecedingTodos, setIdsOfRecedingTodos] = useState<number[]>([]);
const [tempTodo, setTempTodo] = useState<Todo | null>(null);
const [idsOfTodosOnSelect, setIdsOfTodosOnSelect] = useState<number[]>([]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think idsOfRecedingTodos and idsOfTodosOnSelect can be united in one state

src/App.tsx Outdated
Comment on lines 248 to 258
function allSelected() {
setFilter(Filter.all);
}

function activeSelected() {
setFilter(Filter.active);
}

function completedSelected() {
setFilter(Filter.completed);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's redundant to create three functions and pass them into Footer, just pass the setFilter function

Copy link

@anastasiiavorobiova anastasiiavorobiova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants