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

Month 12/step 1 #1

Merged
merged 33 commits into from
Jun 18, 2022
Merged

Month 12/step 1 #1

merged 33 commits into from
Jun 18, 2022

Conversation

LexorV
Copy link
Owner

@LexorV LexorV commented Jun 12, 2022

No description provided.

}
//Пока не до конца типизировано. В работе.
import { ElementStates } from '../../types/element-states';
interface ILinkedList<T> {

Choose a reason for hiding this comment

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

Надо исправить: Все импорты должы располагаться в начале файла. Из-за этого могут вылазить ошибки компиляции

Math.random().toString(36);
export function randomNumber(max: number, min: number) {
return Math.floor(Math.random() * (max - min) + min);
}

Choose a reason for hiding this comment

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

Можно лучше: Мне кажется этот фрагмент кода, для него лучше подходит папка utils

Обсуждение на этот счет: erikras/react-redux-universal-hot-example#808

const [textInput, setTextInput] = useState<string>('');
const [arrText, setArrText] = useState<TobjectText[]>([]);
const [hightIndex, setHight] = useState<number | null>(null)
const [started, setStarted] = useState<boolean>(false)
Copy link

@kyzinatra kyzinatra Jun 12, 2022

Choose a reason for hiding this comment

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

Можно лучше: hightIndex нигде не используется, его можно удалить

if(arrText.length > 1 && started == false) {
startAlgo()
}
},[arrText])
Copy link

@kyzinatra kyzinatra Jun 12, 2022

Choose a reason for hiding this comment

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

Можно лучше: Мне кажется, что вместо того, чтобы проверять константу started, запускать алгоритм лучше по нажатию на кнопку (onClick)

})
setHight(hight)
copy[low].style = ElementStates.Modified
copy[hight].style = ElementStates.Modified
Copy link

@kyzinatra kyzinatra Jun 12, 2022

Choose a reason for hiding this comment

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

Надо исправить: Сам алгоритм (технические вычисления, не рендер) стоит вынести в отдельный файл в string/utils. К примеру создать там функцию getReversingStringSteps, которая бы расписывала шаги, а рендер уже производить в компоненте

setTimeout(() => {
res()
}, 500)
})
Copy link

@kyzinatra kyzinatra Jun 12, 2022

Choose a reason for hiding this comment

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

Надо исрпавить: По аналогии стоит вынести сам алгоритм генерации чисел фибоначи в отдельный файл, а тут просто выводить результат его работы.

По аналогии в каждом компоненте алгоритов

type="number"
isLimitText={true}
max={19}
value={numberInput}

Choose a reason for hiding this comment

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

Можно лучше: При числах > 19 стоит блокировать пользователю кнопку запуска

setArr: any,
setChange: any,
setStarted: any) {
this.arr = arr;

Choose a reason for hiding this comment

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

Надо исправить: не стоит использовать значения any. Стоит либо их строго типизировать, либо использовать дженерики

const [textInput, setTextInput] = useState<string>('');
const [indexInput, setIndexInput] = useState<number>(0)
const [listArray, setListArray] = useState<any[]>([]);
const [stateChange, setChange] = useState<boolean>(false);

Choose a reason for hiding this comment

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

Надо исправить: по аналогии стоит типизировать хук

<Column
key={nanoid()}
index={el.number}
state={el.style}

Choose a reason for hiding this comment

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

Можно лучше: При сортировке выбором стоит подсветить каким-нибудь отдельным цветом элементы которые на данным момент максимальные и минимальные

await selectionSort(diogrammArr, setindexSort, setDiogrammArr, direction)
}
else {
await bubbleSort(diogrammArr, setindexSort, setDiogrammArr, direction)

Choose a reason for hiding this comment

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

Надо исправить: Сам рендер стоит оставить на компонент. Для utils только техническая часть реализации

setterColor: React.Dispatch<React.SetStateAction<boolean>>
) => void;
clear(
setfield:React.Dispatch<React.SetStateAction<string>>
Copy link

@kyzinatra kyzinatra Jun 12, 2022

Choose a reason for hiding this comment

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

Надо исправить: По аналогии с предыдущим. Рендер стоит оставить компоненту

По аналогии везде где в utils осуществляет рендер

return (
<li key={nanoid()} >
<Circle
head={list.head}

Choose a reason for hiding this comment

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

Надо исправить: если в input нет данных, то стоит заблокировать кнопки добавить

<Circle
head={list.head}
index={index}
letter={list.text}

Choose a reason for hiding this comment

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

Надо исправить:

  • Если удалять элементы из tail то на последнем элементе зависает, а если удалять постоянно по индексу 0, то после добавления не отображается tail
    Скорее всего это связано с неверной реализацией рендера utils. Я думаю, что если организовать техническую часть в utils а рендер тут, то найти баг не составит труда

Copy link

@kyzinatra kyzinatra left a comment

Choose a reason for hiding this comment

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

Выглядит очень круто! Видно, что проделана большая работа.

Что важно исправить:

  • Распологать в utils техническую, но не сам рендер
  • Исправить некоторые баги в очереди
  • Не использовать any без необходиости
  • Блокировать input если в нем нет текста

Можно лучше:

  • В хуке useEffect (А также в любых функциях, что выполняют асинхронные действия) вызывать useState стооит только если компонент действительно существует. Иначе, если выйти из страницы с неоконченным выполнением алгоритма возникает такая ошибка:
react_devtools_backend.js:4026 Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
at StringComponent ([http://localhost:3000/static/js/bundle.js:2603:84](http://localhost:3000/static/js/bundle.js:2603:84))

Именно поэтому важно очищать все асинхронные запросы при размонтировании компонента. Это можно сделать примерно вот так:

useEffect(()  {

let isComponentMounted = true;

await someAsyncStuff(()  {
if (isComponentMounted ) doMagic()

})

return  ()  {isComponentMounted  = false};

})
  • Удалить неиспользуемые переменные

Что понравилось:

  • Верстка соответствует макету и сделана хорошо
  • Хорошо реализован роутинг и композиция компонентов

Обратите внимание, что работа принимается только после исправления всех «Надо исправить».

@kyzinatra
Copy link

Поздравляю! Ваша работа принята.

Вы отлично потрудились.

Удачного дальнейшего обучения.

@LexorV LexorV merged commit 8dd714f into main Jun 18, 2022
@LexorV LexorV deleted the month-12/step-1 branch June 18, 2022 17:29
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