From 34e216546151eaf8a0a3cbb0bc8b65dae4c63bf2 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 23 May 2022 14:07:02 +0200 Subject: refactor: reduce the number of data transformation --- src/components/organisms/layout/comments-list.tsx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/components/organisms/layout/comments-list.tsx') diff --git a/src/components/organisms/layout/comments-list.tsx b/src/components/organisms/layout/comments-list.tsx index f04354c..97eccb7 100644 --- a/src/components/organisms/layout/comments-list.tsx +++ b/src/components/organisms/layout/comments-list.tsx @@ -1,13 +1,10 @@ import SingleComment, { type CommentProps, } from '@components/organisms/layout/comment'; +import { Comment } from '@ts/types/app'; import { FC } from 'react'; import styles from './comments-list.module.scss'; -export type Comment = Omit & { - child?: Comment[]; -}; - export type CommentsListProps = Pick & { /** * An array of comments. @@ -42,7 +39,7 @@ const CommentsList: FC = ({ ): JSX.Element[] => { const isLastLevel = startLevel === depth; - return commentsList.map(({ child, ...comment }) => ( + return commentsList.map(({ replies, ...comment }) => (
  • = ({ saveComment={saveComment} {...comment} /> - {child && !isLastLevel && ( -
      {getItems(child, startLevel + 1)}
    + {replies && !isLastLevel && ( +
      {getItems(replies, startLevel + 1)}
    )}
  • )); -- cgit v1.2.3