Skip to content

Conversation

astrodelete
Copy link
Owner

No description provided.

Copy link

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

const [isLoading, setLoadingState] = useState(false);
const [countUsedKeys, setCountUsedKeys] = useState(0);

const toggleLoading = useCallback(() => {

Choose a reason for hiding this comment

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

Удалить toggleLoading

}, [isLoading]);

const incrementUsedKeys = () => {
setCountUsedKeys((prevValue) => prevValue++);

Choose a reason for hiding this comment

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

++prevValue

}

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

Choose a reason for hiding this comment

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

--prevValue

setLoadingState(!isLoading);
}, [isLoading]);

const incrementUsedKeys = () => {

Choose a reason for hiding this comment

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

добавить useCallback

setCountUsedKeys((prevValue) => prevValue--);
}, []);

const addKey = useCallback(async () => {

Choose a reason for hiding this comment

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

убрать useCallback

{keys.length && (
<div className="keys">
{keys.map((key) => (
<Key

Choose a reason for hiding this comment

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

key={key}

{keys.map((key) => (
<Key
value={key}
removeKey={removeKey(key)}

Choose a reason for hiding this comment

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

removeKey={removeKey}

);
};

export function Key({

Choose a reason for hiding this comment

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

добавить memo

[incrementUsedKeys, isUsed, toggleLoading]
);

useEffect(async () => {

Choose a reason for hiding this comment

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

убрать async

);

useEffect(async () => {
return async () => {

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