강의

멘토링

커뮤니티

Inflearn Community Q&A

minuk35087850's profile image
minuk35087850

asked

Web game that lets you learn by following along

#2-4 Interacting with React and PlayCanvas (window.postMessage)

Ref를 만드신 이유에 대해서 질문드립니다.

Written on

·

246

0

Ref를 만들어준 이유가 단지 clearTimeout을 실행하기 위해서 만든 setTimeout 바구니(?) 인가요~?

만약 그렇다면 Ref말고 다른 방식으로 clearTimeout을 실행시켜도 되는 거죠?

react

Answer 1

1

John Ahn님의 프로필 이미지
John Ahn
Instructor

안녕하세요 minuk님!! 

맞습니다!!! 

Ref 만든 이유는 clearTimeout 실행하려고 했습니다 ~ 

만약 useEffect 안에서 settimeout이랑 cleartimeout 둘 다 하면 굳이 ref 안 만들고 변수 처리해서 바로 cleartimeout 해주셔도 됩니다. 

 

감사합니다!!

minuk35087850's profile image
minuk35087850

asked

Ask a question