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 rask solution #1101

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

add rask solution #1101

wants to merge 2 commits into from

Conversation

shymdima
Copy link

Copy link

@volodymyr-soltys97 volodymyr-soltys97 left a comment

Choose a reason for hiding this comment

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

Good job 👍
Let's improve your code

import { useState } from 'react';
import { Todo } from '../types/Todo';

export function useLocalStorage(key: string, initialState: Todo[]) {

Choose a reason for hiding this comment

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

It is important to follow the same way of creating functions everywhere

Suggested change
export function useLocalStorage(key: string, initialState: Todo[]) {
export const useLocalStorage = (key: string, initialState: Todo[]) => {

<nav className="filter" data-cy="Filter">
<a
href="#/"
className={classNames('filter__link', { selected: filter === 'All' })}

Choose a reason for hiding this comment

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

Create a enum for 'All', 'Active', 'Completed' and use it everywhere

Comment on lines 23 to 44
<a
href="#/"
className={classNames('filter__link', { selected: filter === 'All' })}
data-cy="FilterLinkAll"
onClick={() => { setFilter('All') }}
>
All
</a>

<a
href="#/active"
className={classNames('filter__link', {
selected: filter === 'Active',
})}
data-cy="FilterLinkActive"
onClick={() => {
setFilter('Active');
}}
>
Active
</a>

Choose a reason for hiding this comment

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

Use Object.values(your created enum) and render these options with map() method

return (
<div
data-cy="Todo"
className={classNames('todo', { completed: todo.completed })}

Choose a reason for hiding this comment

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

Suggested change
className={classNames('todo', { completed: todo.completed })}
className={classNames('todo', { completed })}


export const App: React.FC = () => {
const { todos } = useLocalStorageContext();

localStorage.removeItem('todoss');

Choose a reason for hiding this comment

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

Suggested change
localStorage.removeItem('todoss');

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