리액트
Receives *all* click events
avocado12
2021. 5. 12. 13:10
DOM 리스너를 추가 document.addEventListener(...)하면 React 이벤트를 확인 할 수 있습니다.
React 16 및 이전 버전에서는 e.stopPropagation() React 이벤트 핸들러를 호출하더라도 여전히 수신이 가능하지만
React 17을 사용하면 document 핸들러가 실행되지 않습니다.
캡처 단계를 사용하도록 리스너를 변환하여 이와 같은 코드를 수정할 수 있습니다.
document.addEventListener('click', function() {
// Now this event handler uses the capture phase,
// so it receives *all* click events below!
}, { capture: true });
.만