mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 11:17:49 +01:00
33 lines
729 B
TypeScript
33 lines
729 B
TypeScript
import * as React from 'react';
|
|
|
|
import Comment from './Comment';
|
|
|
|
import IComment from '../../interfaces/IComment';
|
|
|
|
interface Props {
|
|
comments: Array<IComment>;
|
|
parentId: number;
|
|
level: number;
|
|
}
|
|
|
|
const CommentList = ({ comments, parentId, level }: Props) => (
|
|
<React.Fragment>
|
|
{comments.map((comment, i) => {
|
|
if (comment.parentId === parentId) {
|
|
return (
|
|
<div className="commentList">
|
|
<Comment level={level} {...comment} />
|
|
|
|
<CommentList
|
|
comments={comments}
|
|
parentId={comment.id}
|
|
level={level+1}
|
|
/>
|
|
</div>
|
|
);
|
|
} else return null;
|
|
})}
|
|
</React.Fragment>
|
|
);
|
|
|
|
export default CommentList; |