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 solution #760

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

Conversation

Daryna-Kukharets
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 your code! There are a few areas for improvement but they don't significantly impact the functionality of your code. Keep up the good work! 😊

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


const filteredPeople = useMemo(() => {
return people.filter(person =>
person.name

Choose a reason for hiding this comment

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

You are directly interacting with DOM here. It's recommended to use React as much as possible. You can use the trim() function when setting the state of appliedQuery instead of using it here.

{filteredPeople.length > 0 ? (
filteredPeople.map(person => (
<div
key={person.slug}

Choose a reason for hiding this comment

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

You are generating a key on render. This can lead to performance issues. It's recommended to generate keys during the creation of items. Here is a link explaining why.


const applyQuery = debounce(setAppliedQuery, delay);

const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {

Choose a reason for hiding this comment

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

The naming convention for this method could be improved. According to the conventions, it's better to name the function onInputChange instead of handleInputChange.

onSelected(null);
};

const handleSelectPerson = (person: Person) => {

Choose a reason for hiding this comment

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

The naming convention for this method could be improved. According to the conventions, it's better to name the function onSelectPerson instead of handleSelectPerson.

const value = event.target.value;

setQuery(value);
applyQuery(value);

Choose a reason for hiding this comment

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

You are not checking if the user entered spaces only. This can lead to unnecessary function calls. You should add a condition to check if the value is not empty or doesn't contain spaces only before calling applyQuery(value).

Copy link

@vadiimvooo vadiimvooo 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

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