Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
[FE] fix: 글 정보가 새로 reload 되지 않는 현상 수정 (#206)
Browse files Browse the repository at this point in the history
* fix: 글 정보가 새로 reload 되지 않는 현상 수정

* refactor: 불필요한 console.log 제거
  • Loading branch information
nangkyeonglim authored Aug 4, 2023
1 parent d18e7e2 commit fe5a59b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -18,10 +18,17 @@ type Props = {
};

const WritingPropertySection = ({ writingId }: Props) => {
const { data: writingInfo } = useGetQuery<GetWritingPropertiesResponse>({
const { data: writingInfo, getData } = useGetQuery<GetWritingPropertiesResponse>({
fetcher: () => getWritingProperties(writingId),
});

useEffect(() => {
const refetch = async () => {
await getData();
};
refetch();
}, [writingId]);

if (!writingInfo) return null;

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export default meta;
type Story = StoryObj<typeof meta>;

export const Primary: Story = {
render: ({ writingId }) => {
render: () => {
return (
<StoryContainer>
<WritingSideBar writingId={writingId} />
<WritingSideBar />
</StoryContainer>
);
},
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/WritingSideBar/WritingSideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ 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',
Publishing = 'Publishing',
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>(TabKeys.WritingProperty);
const [publishTo, setPublishTo] = useState<Blog | null>(null);

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const Layout = () => {
</S.Main>
{isWritingViewerActive && (
<S.RightSidebarSection $isRightSidebarOpen={isRightSidebarOpen}>
<WritingSideBar writingId={activeWritingId} />
<WritingSideBar />
</S.RightSidebarSection>
)}
</S.Row>
Expand Down

0 comments on commit fe5a59b

Please sign in to comment.