diff --git a/frontend/src/components/ArticleBoard/ArticleBoard.jsx b/frontend/src/components/ArticleBoard/ArticleBoard.jsx index 09fe7e5..9e8d378 100644 --- a/frontend/src/components/ArticleBoard/ArticleBoard.jsx +++ b/frontend/src/components/ArticleBoard/ArticleBoard.jsx @@ -1,6 +1,7 @@ import EditIcon from '/src/assets/icons/edit.svg?react'; import { Link } from 'react-router-dom'; import styles from './ArticleBoard.module.css'; +import { Children } from 'react'; export default function ArticleBoard({ title, canCreate, children }) { return ( @@ -19,7 +20,7 @@ export default function ArticleBoard({ title, canCreate, children }) { )}
- {children ? children :
표시할 내용이 없습니다.
} + {Children.toArray(children).length ? children :
표시할 내용이 없습니다.
}
); diff --git a/frontend/src/pages/FreeboardListPage/FreeboardListPage.jsx b/frontend/src/pages/FreeboardListPage/FreeboardListPage.jsx index 9cc6462..badfe77 100644 --- a/frontend/src/pages/FreeboardListPage/FreeboardListPage.jsx +++ b/frontend/src/pages/FreeboardListPage/FreeboardListPage.jsx @@ -7,14 +7,14 @@ import IntersectionArea from '../../components/IntersectionArea/IntersectionObse export default function NoticeListPage() { const { lectureId } = useParams(); const { data, fetchNextPage, hasNextPage } = useFreeboards(lectureId); - const articles = data?.pages.flatMap((page) => page.data); + const articles = data.pages.flatMap((page) => page.data); return ( - {articles.length && + {articles.length > 0 && articles.map?.((notice) => ( page.data); + const notices = data.pages.flatMap((page) => page.data); const userType = useBoundStore((state) => state.userType); return ( @@ -16,7 +16,7 @@ export default function NoticeListPage() { title="공지사항" canCreate={userType === 'teacher'} > - {notices.length && + {notices.length > 0 && notices.map?.((notice) => ( - {questions.length && + {questions.length > 0 && questions.map?.((question) => ( - {quizsets.length && + {quizsets.length > 0 && quizsets.map?.((quizset) => ( - {students.length && + {students.length > 0 && students.map?.((student) => { return ( - {reports.length && + {reports.length > 0 && reports.map?.((report) => { return (