강의

멘토링

커뮤니티

Inflearn Community Q&A

geunhee02123438's profile image
geunhee02123438

asked

[React Part 1] Learning React by Building and Comparing

[Pure JS 2] Recent Searches 2

bindEvents 내부에서 슈퍼클래스의 bindEvents 메서드를 호출 하는 이유가 있을까요?

Resolved

Written on

·

284

0

HistoryListView의 bindEvents에서 슈퍼 클래스의 bindEvents를 호출 해야 하는 이유가 있을까요?

서브 클래스에서 super() 호출로 슈퍼클래스가 초기화될 때 슈퍼 클래스의 bindEvents가 history-list-view 요소를 대상으로 한 번 더 호출되니 안 해줘도 되지 않을까 하는데 제가 잘못 이해하는 것인지 궁금합니다..

 

bindEvent = () => {
    delegate(this.element, 'click', 'button.btn-remove', this.handleRemove);

    super.bindEvent(); // 👈 
  }
reactMVC

Answer 1

1

jeonghwan님의 프로필 이미지
jeonghwan
Instructor

지적해 주신게 맞네요. 이미 생성자 함수에서 bindEvent()를 호출하고 있었습니다. 이렇게되면 두번 호출되는 것이라서 중복이네요. 꼼꼼히 챙겨주셔고 고맙습니다.

geuni님의 프로필 이미지
geuni
Questioner

유익한 강의 잘 보고 있습니다! 답변 감사합니다!

geunhee02123438's profile image
geunhee02123438

asked

Ask a question