Skip to content

Нягу Никита#16

Open
astrodelete wants to merge 2 commits into
mainfrom
interview
Open

Нягу Никита#16
astrodelete wants to merge 2 commits into
mainfrom
interview

Conversation

@astrodelete
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown

@ChristmasWoe ChristmasWoe left a comment

Choose a reason for hiding this comment

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

Comment thread src/components/App.tsx
const [isLoading, setLoadingState] = useState(false);
const [countUsedKeys, setCountUsedKeys] = useState(0);

const toggleLoading = useCallback(() => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Удалить toggleLoading

Comment thread src/components/App.tsx
}, [isLoading]);

const incrementUsedKeys = () => {
setCountUsedKeys((prevValue) => prevValue++);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

++prevValue

Comment thread src/components/App.tsx
}

const decrementUsedKeys = useCallback(() => {
setCountUsedKeys((prevValue) => prevValue--);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

--prevValue

Comment thread src/components/App.tsx
setLoadingState(!isLoading);
}, [isLoading]);

const incrementUsedKeys = () => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

добавить useCallback

Comment thread src/components/App.tsx
setCountUsedKeys((prevValue) => prevValue--);
}, []);

const addKey = useCallback(async () => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

убрать useCallback

Comment thread src/components/App.tsx
{keys.length && (
<div className="keys">
{keys.map((key) => (
<Key
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

key={key}

Comment thread src/components/App.tsx
{keys.map((key) => (
<Key
value={key}
removeKey={removeKey(key)}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

removeKey={removeKey}

Comment thread src/components/App.tsx
);
};

export function Key({
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

добавить memo

Comment thread src/components/App.tsx
[incrementUsedKeys, isUsed, toggleLoading]
);

useEffect(async () => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

убрать async

Comment thread src/components/App.tsx
);

useEffect(async () => {
return async () => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Подход удаления на сервер результатом демонтирования технически допустим, но является антипаттерном, поэтому всю логику удаления ключа необхидмо описать в одном месте. Убрать useEffect

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