Skip to content

Conversation

@nebunohu
Copy link

No description provided.

Copy link

@vitalymuravyev vitalymuravyev left a comment

Choose a reason for hiding this comment

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

для работы с svg  очень популярна вот эта тема https://react-svgr.com, инлайнить их плохая практика

Оказывается эта тема поддерживается с версии 2.0.0, а у нас 1.1.1((

Comment on lines 31 to 35
props.articles.map(article => {
return (
<ArticlePreview article={article} key={article.slug} />
);
})

Choose a reason for hiding this comment

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

можно в одну строчку
map(article => <ArticlePreview ... />);

Copy link
Author

Choose a reason for hiding this comment

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

Мне кажется, что в таком виде код более читаемый. Разве нет?

Copy link

Choose a reason for hiding this comment

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

к такой короткой записи легко привыкнуть, это нормально

Choose a reason for hiding this comment

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

встречается все чаще, действительно быстро привыкаешь, ну и не зря же все эти упрощения вводятся

);
}

if (props.articles.length === 0) {

Choose a reason for hiding this comment

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

Ноль сам по себе дает false, так что можно просто if (props.articles.length)

Copy link
Author

Choose a reason for hiding this comment

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

Можно и так, но тогда if (!props.articles.length)

currentPage: undefined
};

export default ArticleList;

Choose a reason for hiding this comment

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

Мне нравится пропсы деструктуризировать, так код лучше читается, а то от props в глазах рябит

});

const ArticlePreview = props => {
const article = props.article;

Choose a reason for hiding this comment

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

const { article } = props;

Copy link
Author

Choose a reason for hiding this comment

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

А чем именно это лучше?

Copy link
Author

@nebunohu nebunohu Jan 10, 2022

Choose a reason for hiding this comment

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

Я даже присмотрелся и не понял, зачем вообще такая конструкция использовалась, если уж можно деструктуризацию сделать вообще используемых пропсов.
Видимо, когда переписывал просто записал так, чтобы можно было пропс прокинуть дальше

Choose a reason for hiding this comment

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

это просто деструктуризация, считай современный синтаксис.
А так да, если надо прокинуть все пропсы, обычно так делают

Comment on lines +32 to +33
<div className="strange-block" />
<div className="article-preview">

Choose a reason for hiding this comment

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

тут же должны быть <StrangeBlock /> и <ArticlePreviewBlock />

Copy link
Author

Choose a reason for hiding this comment

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

А смысл, если стили к этим дивам можно прописать в компоненте ArticleWrapper и не городить лишних структур? Или есть какие-то рекомендуемые практики?

Choose a reason for hiding this comment

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

Как по мне, подход styled component предполагает использование именно компонентов для стилизации. Классы как-то выбиваются из этой концепции. Сам я первый раз использую этот подход, но смесь компонентов и классов не приходилось встречать

Copy link
Author

Choose a reason for hiding this comment

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

Но для каких целей тогда имеется возможность стилизовать дочерние блоки?

Choose a reason for hiding this comment

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

Если бы я знал) Посмотрим, что Влад ответит.
Спросил пока товарища по опытнее, любителя этой технологии, говорит "Класснеймы примешивать моветон, как мне кажется. Работаешь с компонентами - работай с компонентами". Но опять же "как мне кажется"

Comment on lines 9 to 12
if ( src === defaultAvatarURL ) {
src = defaultAvatarPath;
}
const isDefault = (src === defaultAvatarPath);

Choose a reason for hiding this comment

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

чтобы два раза не вызывать сравнение, можно так:
`let isDefault = false;

if ( src === defaultAvatarURL ) {
src = defaultAvatarPath;
isDefault = true;
}`

Comment on lines +11 to +19
${props => {
switch (props.location) {
default:
case 'profile': {
return 'width: 120px; height: 120px; margin-bottom: 8px;';
}
case 'article': {
return 'width: 48px; height: 48px; margin-right: 8px;';
}

Choose a reason for hiding this comment

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

switch case кажется избыточным, так всего два кейса. Их можно обработать просто есть пропс/нет пропса. И default и big/large кажется более подходящим, вдруг еще где придется потом их использовать

Copy link
Author

Choose a reason for hiding this comment

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

А вдруг нужен будет другой размер для другого места?

Choose a reason for hiding this comment

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

Тогда все гуд. Написал коммент исходя из того, что у нас дизайн 100% не поменяется и кейса два

Comment on lines +7 to +17
& .author {
color: #0A0A0B;
font-size: 16px;
line-height: 24px;
}

& .date {
color: #62626A;
font-size: 12px;
line-height: 16px;
}

Choose a reason for hiding this comment

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

styled

Comment on lines +25 to +29
<Link
className="nav-link "
to={`/`}
onClick={clickHandler}
>

Choose a reason for hiding this comment

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

styledLink

);
} else {
return (
<ul className="nav nav-pills outline-active">

Choose a reason for hiding this comment

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

styled list

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.

4 participants