1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 21:06:42 +07:00

optimized scrolls

This commit is contained in:
Fedor Katurov 2019-10-23 10:42:25 +07:00
parent 948817e8fc
commit f169de370a
12 changed files with 110 additions and 98 deletions

View file

@ -1,4 +1,4 @@
import React, { FC, HTMLAttributes } from 'react';
import React, { FC, HTMLAttributes, memo } from 'react';
import { CommentWrapper } from '~/components/containers/CommentWrapper';
import { ICommentGroup } from '~/redux/types';
import { getURL } from '~/utils/dom';
@ -12,30 +12,25 @@ type IProps = HTMLAttributes<HTMLDivElement> & {
is_same?: boolean;
};
const Comment: FC<IProps> = ({
comment_group,
is_empty,
is_same,
is_loading,
className,
...props
}) => {
return (
<CommentWrapper
className={className}
is_empty={is_empty}
is_loading={is_loading}
user={comment_group.user}
is_same={is_same}
{...props}
>
<div className={styles.wrap}>
{comment_group.comments.map(comment => (
<CommentContent comment={comment} key={comment.id} />
))}
</div>
</CommentWrapper>
);
};
const Comment: FC<IProps> = memo(
({ comment_group, is_empty, is_same, is_loading, className, ...props }) => {
return (
<CommentWrapper
className={className}
is_empty={is_empty}
is_loading={is_loading}
user={comment_group.user}
is_same={is_same}
{...props}
>
<div className={styles.wrap}>
{comment_group.comments.map(comment => (
<CommentContent comment={comment} key={comment.id} />
))}
</div>
</CommentWrapper>
);
}
);
export { Comment };

View file

@ -1,4 +1,4 @@
import React, { FC, useMemo } from 'react';
import React, { FC, useMemo, memo } from 'react';
import { IComment, IFile } from '~/redux/types';
import path from 'ramda/es/path';
import { formatCommentText, getURL, getPrettyDate } from '~/utils/dom';
@ -15,7 +15,7 @@ interface IProps {
comment: IComment;
}
const CommentContent: FC<IProps> = ({ comment }) => {
const CommentContent: FC<IProps> = memo(({ comment }) => {
const groupped = useMemo<Record<keyof typeof UPLOAD_TYPES, IFile[]>>(
() =>
reduce(
@ -68,7 +68,7 @@ const CommentContent: FC<IProps> = ({ comment }) => {
)}
</>
);
};
});
export { CommentContent };

View file

@ -29,4 +29,5 @@
background: no-repeat 50% 30%;
background-size: cover;
z-index: 1;
will-change: transform;
}