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

solution #1573

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

solution #1573

wants to merge 1 commit into from

Conversation

VitaliiShc
Copy link

@VitaliiShc
Copy link
Author

VitaliiShc commented Dec 26, 2024

allTestsPassed

Copy link

@VolodymyrKirichenko VolodymyrKirichenko left a comment

Choose a reason for hiding this comment

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

Well done 🔥

const USER_ID = 0;
export const App: FC = () => {
const [todos, setTodos] = useState<Todo[]>([]);
const [errorMessage, setErrorMessage] = useState<ErrorMessage | null>(null);

Choose a reason for hiding this comment

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

u don't need null for this state.
ErrorMessage.default = ''

Suggested change
const [errorMessage, setErrorMessage] = useState<ErrorMessage | null>(null);
const [errorMessage, setErrorMessage] = useState<ErrorMessage>(ErrorMessage.Default);

Comment on lines +28 to +34
(async () => {
try {
setTodos(await getTodos());
} catch (err) {
setErrorMessage(ErrorMessage.LoadError);
}
})();

Choose a reason for hiding this comment

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

  1. will be better, right?
    1. It is better to move all useEffect to the bottom(before render), for better support, and readability
Suggested change
(async () => {
try {
setTodos(await getTodos());
} catch (err) {
setErrorMessage(ErrorMessage.LoadError);
}
})();
const getAllTodos = async () => {
try {
setTodos(await getTodos());
} catch (err) {
setErrorMessage(ErrorMessage.LoadError);
}
}
getAllTodos();


const activeTodosQuantity = useMemo(() => activeTodos.length, [activeTodos]);

const addNewTodoHandler = async (title: string) => {

Choose a reason for hiding this comment

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

useCallback?


type Props = {
filterValue: StatusFilter;
setFilterValue: Dispatch<SetStateAction<StatusFilter>>;

Choose a reason for hiding this comment

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

u can use another syntax(up to u)

Suggested change
setFilterValue: Dispatch<SetStateAction<StatusFilter>>;
setFilterValue: (filterValue: StatusFilter) => void;

return (
<a
key={value}
href={`#/${value === StatusFilter.All ? '' : value}`}

Choose a reason for hiding this comment

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

more readable

Suggested change
href={`#/${value === StatusFilter.All ? '' : value}`}
href={`#/${value !== StatusFilter.All && value}`}

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.

2 participants