
[마이머니앱] 클린업 함수 추가하기/ 로그인 및 로그인 시 유저정보 가져오기
·
FRONTEND/React
작업이 끝나기전에 화면이동이나 종료를 하면 오류가 발생할 수 있으므로 현재 진행중인 작업을 취소하는 클린업 함수를 추가할것 useLogout.js에 취소 여부를 담는 state를 생성한다. const [isCancelled, setIsCancelled] = useState(false); useEffect(() => { setIsCancelled(false); // 로그아웃 작업중 중간에 사라진다면 // useEffect의 return이 unmount될때의 작업(클린업)이 된다. return () => setIsCancelled(true); }, []); return { logout, error, isPending }; }; 그리고 위의 try catch도 바꿔준다. const logout = async ..