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 #2615

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

solution #2615

wants to merge 1 commit into from

Conversation

imondok03
Copy link

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Great job on the pull request! 🎉 While there are some suggestions for improvements, they are mostly related to naming conventions and best practices that don't critically impact functionality. Keep up the good work and consider the feedback for future enhancements!

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

const [isLoaded, setIsLoaded] = useState(false);
const [selectedTodo, setSelectedTodo] = useState<Todo | undefined>(undefined);
const [selectedStatus, setSelectedStatus] = useState('all');
const [query, setSelectedQuery] = useState('');

Choose a reason for hiding this comment

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

The state setter function here is named setSelectedQuery, but it should be setQuery to match the state variable name query. This follows the naming convention for state setter functions.

setTodos(filteredResult);
setIsLoaded(true);
});
}, [selectedStatus, query]);

Choose a reason for hiding this comment

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

Using props to initialize state directly can lead to unexpected behavior. Consider using a function inside useState or handling it differently to avoid potential issues.

@@ -17,18 +46,30 @@ export const App: React.FC = () => {
<h1 className="title">Todos:</h1>

<div className="block">
<TodoFilter />
<TodoFilter
onSelect={setSelectedStatus}

Choose a reason for hiding this comment

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

The naming convention for event handler props suggests using onStatusSelect instead of onSelect to make it more descriptive and specific to the action.

<TodoFilter />
<TodoFilter
onSelect={setSelectedStatus}
onChange={setSelectedQuery}

Choose a reason for hiding this comment

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

The naming convention for event handler props suggests using onQueryChange instead of onChange to make it more descriptive and specific to the action.

<TodoList
todos={todos}
selectedTodo={selectedTodo}
onSelect={setSelectedTodo}

Choose a reason for hiding this comment

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

The naming convention for event handler props suggests using onTodoSelect instead of onSelect to make it more descriptive and specific to the action.

<tr
data-cy="todo"
className={`${id === selectedId && 'has-background-info-light'}`}
key={id}

Choose a reason for hiding this comment

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

Generating keys directly from the id prop is generally fine if id is unique and stable. However, ensure that id is indeed unique across all items to avoid potential issues.

Comment on lines +18 to +22
const onEscape = (event: KeyboardEvent) => {
if (event.key === 'Escape') {
onClose(undefined);
}
};

Choose a reason for hiding this comment

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

The naming convention for event handler functions should follow the pattern handleEventName. Consider renaming onEscape to handleEscape to align with the recommended naming conventions.

Comment on lines +29 to +30
document.addEventListener('keydown', onEscape);
});

Choose a reason for hiding this comment

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

Directly interacting with the DOM using document.addEventListener is not recommended in React. Consider using a cleanup function in useEffect to remove the event listener when the component unmounts.

setLoader(true);
});
document.addEventListener('keydown', onEscape);
});

Choose a reason for hiding this comment

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

The useEffect hook should have a dependency array to avoid running on every render. Consider adding userId as a dependency to ensure the effect only runs when userId changes.

type="button"
className="delete"
data-cy="modal-close"
onClick={() => onClose(undefined)}

Choose a reason for hiding this comment

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

The naming convention for event handler functions should follow the pattern handleEventName. Consider renaming the inline function to handleClose to align with the recommended naming conventions.

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