Skip to content

Solution#1172

Open
OlehYuriev wants to merge 1 commit into
mate-academy:masterfrom
OlehYuriev:develop
Open

Solution#1172
OlehYuriev wants to merge 1 commit into
mate-academy:masterfrom
OlehYuriev:develop

Conversation

@OlehYuriev
Copy link
Copy Markdown

import { Person } from '../../types/Person';

type Prop = {
visible: boolean;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

it's common practice to name boolean consts, props, arguments using prefixes like has, is, are. e.g. hasAccess, areEquals etc

onClick={() => onSelected(item)}
>
<p
className={`${item.sex === 'f' ? 'has-text-danger' : 'has-text-link'}`}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

use classnames for conditional classes

Comment thread src/App.tsx
import { Dropdown } from './components/Dropdown/Dropdown';
import { useDebounce } from './hooks/useDebounce';

function filteredPerson(people: Person[], query: string): Person[] {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bad function naming, function names usually should indicate an action. in your case it's named like it is a filtered person and not an action

Comment thread src/App.tsx
function filteredPerson(people: Person[], query: string): Person[] {
const queryLowerCase = query.trim().toLowerCase();

if (query !== '') {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

i assume the check should be queryLowerCase !== '' instead.

in your current functionality you are trimming the queryLowerCase but checking query which means that if query has empty spaces like ' ' it would be valid for if condition

people: Person[];
onSelected: (person: Person) => void;
};
export const Dropdown = memo(function Dropdown({
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

it looks like unnecessary memoization

Comment thread src/App.tsx
Comment on lines +77 to +82
onChange={e => {
setSearch(e.target.value);
if (selectedPerson) {
setSelectedPerson(null);
}
}}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

inline event handlers that exceeds one line should be moved into named handlers

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