diff --git a/frontend/src/components/WritingPropertySection/WritingPropertySection.tsx b/frontend/src/components/WritingPropertySection/WritingPropertySection.tsx index e20d9049d..aa4202103 100644 --- a/frontend/src/components/WritingPropertySection/WritingPropertySection.tsx +++ b/frontend/src/components/WritingPropertySection/WritingPropertySection.tsx @@ -1,4 +1,4 @@ -import { Fragment, ReactElement } from 'react'; +import { Fragment, ReactElement, useEffect } from 'react'; import { getWritingProperties } from 'apis/writings'; import { CalendarIcon, MediumLogoIcon, TagIcon, TistoryLogoIcon } from 'assets/icons'; import Tag from 'components/@common/Tag/Tag'; @@ -18,10 +18,17 @@ type Props = { }; const WritingPropertySection = ({ writingId }: Props) => { - const { data: writingInfo } = useGetQuery({ + const { data: writingInfo, getData } = useGetQuery({ fetcher: () => getWritingProperties(writingId), }); + useEffect(() => { + const refetch = async () => { + await getData(); + }; + refetch(); + }, [writingId]); + if (!writingInfo) return null; return ( diff --git a/frontend/src/components/WritingSideBar/WritingSideBar.stories.tsx b/frontend/src/components/WritingSideBar/WritingSideBar.stories.tsx index e32e0fae5..6aef36eb1 100644 --- a/frontend/src/components/WritingSideBar/WritingSideBar.stories.tsx +++ b/frontend/src/components/WritingSideBar/WritingSideBar.stories.tsx @@ -20,10 +20,10 @@ export default meta; type Story = StoryObj; export const Primary: Story = { - render: ({ writingId }) => { + render: () => { return ( - + ); }, diff --git a/frontend/src/components/WritingSideBar/WritingSideBar.tsx b/frontend/src/components/WritingSideBar/WritingSideBar.tsx index c3aea832f..35e30c0c6 100644 --- a/frontend/src/components/WritingSideBar/WritingSideBar.tsx +++ b/frontend/src/components/WritingSideBar/WritingSideBar.tsx @@ -8,6 +8,7 @@ import { useState } from 'react'; import { Blog } from 'types/domain'; import WritingPropertySection from 'components/WritingPropertySection/WritingPropertySection'; import Button from 'components/@common/Button/Button'; +import { useParams } from 'react-router-dom'; export enum TabKeys { WritingProperty = 'WritingProperty', @@ -15,15 +16,14 @@ export enum TabKeys { PublishingProperty = 'PublishingProperty', } -type Props = { writingId: number }; - const ariaLabelFromTabKeys = { [TabKeys.WritingProperty]: '글 정보', [TabKeys.Publishing]: '발행 하기', [TabKeys.PublishingProperty]: '발행 정보', }; -const WritingSideBar = ({ writingId }: Props) => { +const WritingSideBar = () => { + const writingId = Number(useParams()['writingId']); const { currentTab, selectCurrentTab } = useCurrentTab(TabKeys.WritingProperty); const [publishTo, setPublishTo] = useState(null); diff --git a/frontend/src/pages/Layout/Layout.tsx b/frontend/src/pages/Layout/Layout.tsx index 7ce9cc6fd..20ddc1274 100644 --- a/frontend/src/pages/Layout/Layout.tsx +++ b/frontend/src/pages/Layout/Layout.tsx @@ -66,7 +66,7 @@ const Layout = () => { {isWritingViewerActive && ( - + )}