2017-11-30 3 views

답변

3

라이프 사이클 메소드는 React의 코드에서 '정의'되어 있지 않습니다. 말하자면 라이프 사이클 메소드는 라이프 사이클의 특정 시점에 컴포넌트의 인스턴스에 있는지 여부를 단순히 확인하고, 그렇다면 실행합니다.

예를 들어, 다음 some of the code from the React reconciler package that checks shouldComponentUpdate입니다 :

if (typeof instance.shouldComponentUpdate === 'function') { 
    startPhaseTimer(workInProgress, 'shouldComponentUpdate'); 
    const shouldUpdate = instance.shouldComponentUpdate(
    newProps, 
    newState, 
    newContext, 
); 
    stopPhaseTimer(); 

    /* ...and so on... */ 

    return shouldUpdate; 
}