본문 바로가기

프로젝트/쩝쩝박사

[프로젝트/쩝쩝박사] MainContainer Error

Uncaught Error: Too many re-renders. React limits the number of renders to prevent an infinite loop.

return( ) 안에 함수를 작성할때 나타나는 오류. useEffect안에 작성해줘야 함

 

 

해결 안되는 것

1. useEffect의 두번째 파라미터로 loading_items를 넣으면 무한루프. 반복된 요청으로 유튜브 api할당량 초과로 403 ERROR

 useEffect(() => {
        
        setYoutubeItems();
        // setVideoComments();
        return (() => {
            console.log('컴포넌트 제거됨')      
            })
    }, [loading_items])

 

 

 

2. 1번과 같은 오류

useEffect(() => {
        if(state.item.data.length !== 0) return;
        setYoutubeItems()

        return (() => {
            setVideoComments();
        })
    }, [state])

'프로젝트 > 쩝쩝박사' 카테고리의 다른 글

20220415(금)  (0) 2022.04.15