• 카테고리

    질문 & 답변
  • 세부 분야

    프론트엔드

  • 해결 여부

    미해결

useEffect 질문있습니다.

21.01.09 18:18 작성 조회수 124

0

    useEffect(() => {  // componentDidMount, componentDidUpdate = 합쳐놓았다고 생각
        console.log('랜덤')
        interval.current = setInterval(changeHand, 100)
        return () => {  // componentWillUnmount
            console.log('랜덤종료')
            clearInterval(interval.current)
        }
    }, [imgCoord])  // componentDidUpdate

componentwillMount가 헷갈리는게

componentDidMount, componentDidUpdate 이후에 바로 실행이 되는건가요~?

아니면 componentDidUpdate가 되면서 기존 컴포넌트가 리렌더링 될 때 일어나나요? 궁금합니다.

답변 2

·

답변을 작성해보세요.

1

새로운 useEffect가 실행되기 직전에 발생합니다.

0

트릴님의 프로필

트릴

질문자

2021.01.11

useEffect에서 componentwillUnMount인데 오타가 났네요... useEffect의 작업이 끝난후 바로 return이 실행되나요?