Skip to content

Commit

Permalink
♻️ Refactor: 불필요한 interval ID 재생성 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
romantech committed Nov 24, 2021
1 parent e075913 commit 8c007e2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Components/NotFoundPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ const NotFoundPage = function ({ history }) {
const [seconds, setSeconds] = useState(5);

useEffect(() => {
const timer = setInterval(() => {
setSeconds(seconds - 1);
if (seconds === 1) history.push('/home');
}, 1000);

const timer = setInterval(() => setSeconds(prev => prev - 1), 1000);
return () => clearInterval(timer);
}, []);

useEffect(() => {
if (seconds === 0) history.push('/home');
}, [history, seconds]);

return (
Expand Down

1 comment on commit 8c007e2

@vercel
Copy link

@vercel vercel bot commented on 8c007e2 Nov 24, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.