Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fetch eventInfo only when the eventId state changes #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/pages/Event.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { IOrderState } from 'src/store/types';
import { Button, Result } from 'antd';

const mapState = (state: IOrderState) => ({
eventId: state.eventId,
eventInfo: state.event,
shopInfo: state.shop,
});
Expand All @@ -21,13 +22,13 @@ type EventProps = RouteComponentProps<{eventId: string}>
& ConnectedProps<typeof connector>;

const Event: React.FC<EventProps> = ({
eventInfo, shopInfo, match, setEvent,
eventId, eventInfo, shopInfo, match, setEvent,
}) => {
const { eventId } = match.params;

useEffect(() => {
setEvent(eventId);
}, [eventId, setEvent]);
if (eventId !== match.params.eventId) {
setEvent(match.params.eventId);
}
}, [match.params.eventId, setEvent]);

if (!eventInfo.loading && !shopInfo.loading && shopInfo === null) {
return (
Expand All @@ -44,7 +45,7 @@ const Event: React.FC<EventProps> = ({
<div style={{ width: 'fit-content', margin: 'auto' }}>
{!eventInfo.loading && eventInfo.data?.title}
<Button size="small" type="link">
<Link to={`./${eventId}/summary`}>접수 현황</Link>
<Link to={`./${match.params.eventId}/summary`}>접수 현황</Link>
</Button> <br/>
</div>
{/* {!!event?.closed && <mark>본 주문은 마감되었습니다</mark>} */}
Expand Down