Closed yanggwangseong closed 1 year ago
const [isLottie, setIsLottie] = useState<boolean>(false); <Lottie className={styles.lottie_container} animationData={heartAnimation} loop={false} lottieRef={lottieRef} onComplete={handleLottieComplete} /> // 내가 찾은거 lottie가 Complete완료가 되면 호출되는 함수 const handleLottieComplete = () => { if (lottieRef.current) { lottieRef.current.stop(); if (lottieRef.current?.animationContainerRef.current) { lottieRef.current.animationContainerRef.current.style.visibility = 'hidden'; } setIsLottie(false); //lottieRef.current.animationContainerRef.current?.style.visibility = 'hidden' //lottieRef.current.animationContainerRef.current?.remove(); } }; useEffect(() => { if (lottieRef.current) { lottieRef.current.stop(); if (lottieRef.current?.animationContainerRef.current) { lottieRef.current.animationContainerRef.current.style.visibility = 'hidden'; } if (isLottie) { lottieRef.current.play(); if (lottieRef.current?.animationContainerRef.current) { lottieRef.current.animationContainerRef.current.style.visibility = 'visible'; } } } }, [isLottie]); const { mutate: feedLikeSync } = useMutation( ['feed-like'], (data: { feedId: string; page: number }) => FeedService.updateLike(data.feedId), { onMutate: variable => { //Loading.hourglass(); }, onSuccess(data, variable) { const pageValue = variable.page; if (data === true) { setIsLottie(true); Notify.success('좋아요를 누르셨습니다'); } if (data === false) { Notify.warning('좋아요를 취소하셨습니다'); } refetch({ refetchPage: (page, index) => index === pageValue - 1 }); //Loading.remove(); //if (data) Report.success('성공', `좋아요를 성공 하였습니다`, '확인'); //Report.success('성공', `좋아요를 취소 하였습니다`, '확인'); }, onError(error) { if (axios.isAxiosError(error)) { Report.warning( '실패', `${error.response?.data.message}`, '확인', () => Loading.remove(), ); } }, }, );
✨ 구현 기능 명세
🎁 주목할 점
😭 어려웠던 점
🌄 스크린샷