Skip to content
Merged
Show file tree
Hide file tree
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: 8 additions & 5 deletions src/app/post-meetup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { PreUploadGroupImageResponse } from '@/types/service/group';

const PostMeetupPage = () => {
const { replace } = useRouter();

const { mutateAsync: createGroup } = useCreateGroup();

const form = useForm({
Expand All @@ -34,11 +33,9 @@ const PostMeetupPage = () => {
images: [],
} as CreateGroupFormValues,
validators: {
onSubmit: createGroupSchema,
onChange: createGroupSchema,
},
onSubmit: async ({ value }) => {
console.log(value);

const images = [] as PreUploadGroupImageResponse['images'];

if (value.images) {
Expand All @@ -51,6 +48,7 @@ const PostMeetupPage = () => {
}

const res = await createGroup({ ...value, images: images });

replace(`/meetup/${res.id}`);
},
});
Expand All @@ -74,7 +72,12 @@ const PostMeetupPage = () => {
<form.Field children={(field) => <MeetupTagsField field={field} />} name='tags' />
</section>

<MeetupSubmitButton onSubmitClick={() => form.handleSubmit()} />
<form.Subscribe
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subscribe
미국∙영국 [səbˈskraɪb]
영국식

동사
1
(신문 등을) 구독하다, (인터넷·유료 TV 채널 등에[을]) 가입[시청]하다
Which journals does the library subscribe to?

이 도서관에서는 어떤 저널들을 구독하나요?
2
(단체에 유료 회원으로) 가입하다, (자선 단체에 정기적으로) 기부하다
He subscribes regularly to Amnesty International.

그는 국제 사면 위원회에 정기적으로 기부를 한다.
3
(주식을 사기 위해) 청약[신청]하다 (→oversubscribed)

정답:

Copy link
Member Author

@HopeFullee HopeFullee Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

정답: 1번

  • <form.Subscribe /> 태그에서부터 알수 있듯이 form 에 구독을 해서 form 의 meta 정보 ("isSubmitting" 등..) 를 실시간으로 받아옴.
  • Subscribe의 특이점: 구독을 통해 form의 meta 정보를 얻어올땐 form 자체는 re-render가 발생하지 않고 오로지 구독을 하고 있는 children만 re-render를 함.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

children={(state) => (
<MeetupSubmitButton state={state} onSubmitClick={() => form.handleSubmit()} />
)}
selector={(state) => state}
/>
</form>
</div>
);
Expand Down
11 changes: 9 additions & 2 deletions src/components/pages/post-meetup/post-button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { AnyFormState } from '@tanstack/react-form';

import { Button } from '@/components/ui';

interface Props {
state: AnyFormState;
onSubmitClick: () => void;
}

export const MeetupSubmitButton = ({ onSubmitClick }: Props) => {
export const MeetupSubmitButton = ({ state, onSubmitClick }: Props) => {
const { canSubmit, isSubmitted, isPristine } = state;

const isSubmitDisabled = !canSubmit || isSubmitted || isPristine;

return (
<div className='mt-6 border-t-1 border-gray-200 bg-white px-4 py-3'>
<Button type='button' onClick={onSubmitClick}>
<Button disabled={isSubmitDisabled} type='button' onClick={onSubmitClick}>
모임 생성
</Button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/use-group/use-group-create/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CreateGroupPayload } from '@/types/service/group';
export const useCreateGroup = () => {
const query = useMutation({
mutationFn: (payload: CreateGroupPayload) => API.groupService.createGroup(payload),
onSuccess: () => {
onSuccess: async () => {
console.log('모임 생성 성공.');
},
onError: () => {
Expand Down