Skip to content

Commit

Permalink
fix(client): useShowConfettiEffect -> useShowConfetti로 네이밍 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
SEOKKAMONI committed May 5, 2024
1 parent 8b23a2a commit 32da647
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useQueryClient } from '@tanstack/react-query';
import { useAcceptCoffeechat } from '@/hooks/api/coffeechat/useAcceptCoffeechat';
import { RECEIVE_COFFEE_CHAT_LIST } from '@/hooks/api/coffeechat/useGetReceiveCoffeechatList';
import { USER_QUERY_KEY } from '@/hooks/api/user/useGetUser';
import { useShowConfettiEffect } from '@/hooks/common/useShowConfettiEffect';
import { useShowConfetti } from '@/hooks/common/useShowConfetti';
import { useLogAnalyticsEvent } from '@/libs/logging';

type CoffeechatAcceptConfirmProps = {
Expand All @@ -17,7 +17,7 @@ const CoffeechatAcceptConfirm = ({
}: CoffeechatAcceptConfirmProps) => {
const queryClient = useQueryClient();
const { logClickEvent } = useLogAnalyticsEvent();
const { showConfettiEffect } = useShowConfettiEffect();
const { showConfetti } = useShowConfetti();
const { mutate: acceptCoffeechatMutate } = useAcceptCoffeechat(coffeechatId, {
onSuccess: () => {
logClickEvent({
Expand All @@ -28,7 +28,7 @@ const CoffeechatAcceptConfirm = ({
});
queryClient.invalidateQueries({ queryKey: [RECEIVE_COFFEE_CHAT_LIST] });
queryClient.invalidateQueries({ queryKey: [USER_QUERY_KEY] });
showConfettiEffect();
showConfetti();
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useForm } from 'react-hook-form';
import { SEND_COFFEE_CHAT_LIST } from '@/hooks/api/coffeechat/useGetSendCoffeechatList';
import { useSendCoffeechat } from '@/hooks/api/coffeechat/useSendCoffeechat';
import type { SendCoffeechatRequest } from '@/hooks/api/coffeechat/useSendCoffeechat';
import { useShowConfettiEffect } from '@/hooks/common/useShowConfettiEffect';
import { useShowConfetti } from '@/hooks/common/useShowConfetti';
import { useLogAnalyticsEvent } from '@/libs/logging';
import { useToast } from '@/libs/toast';

Expand All @@ -25,7 +25,7 @@ const CoffeechatSendConfirm = ({
const router = useRouter();
const queryClient = useQueryClient();
const { toast } = useToast();
const { showConfettiEffect } = useShowConfettiEffect();
const { showConfetti } = useShowConfetti();
const { logClickEvent } = useLogAnalyticsEvent();
const {
register,
Expand All @@ -38,7 +38,7 @@ const CoffeechatSendConfirm = ({
logClickEvent({ name: 'click_send_coffeechat', params: sendCoffeechatRequest });
queryClient.invalidateQueries({ queryKey: [SEND_COFFEE_CHAT_LIST] });
router.replace('/profile');
showConfettiEffect();
showConfetti();
toast.info('커피챗 요청을 보냈어요!', {
action: {
label: '확인하러 가기',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import JSConfetti from 'js-confetti';

export const useShowConfettiEffect = () => {
export const useShowConfetti = () => {
const jsConfetti = new JSConfetti();

const showConfettiEffect = () => {
const showConfetti = () => {
jsConfetti.addConfetti({
confettiColors: ['#7046F7', '#8D6BF9', '#A990FA', '#C6B5FC'],
confettiNumber: 500,
});
};

return { showConfettiEffect };
return { showConfetti };
};
5 changes: 4 additions & 1 deletion packages/ui/src/Portal/hooks/useDidMount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ export const useDidMount = (callback: EffectCallback) => {
const didMountRef = useRef(false);

useEffect(() => {
if (didMountRef.current) return;
if (didMountRef.current) {
return;
}
didMountRef.current = true;

callback();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
};
4 changes: 3 additions & 1 deletion packages/ui/src/Portal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const Portal = ({ isOpen, children }: PortalProps) => {
}
});

if (!container) return null;
if (!container) {
return null;
}

return createPortal(isOpen && children, container);
};
Expand Down

0 comments on commit 32da647

Please sign in to comment.