강의

멘토링

커뮤니티

Inflearn Community Q&A

crystalsujeongna2455's profile image
crystalsujeongna2455

asked

Learning React while making web games

4-1. React conditional statement

새삼스럽게 질문, class method를 이벤트로 부를때는 왜 () 이렇게 안써주나요?

Written on

·

219

0

this.onClickScreen //1

this.renderAverage();//2

둘다 클래스의 매소드를 부르는 건데 

이벤트 함수는 부를때 ()를 왜 안부르나요?

react

Answer 2

0

알아서 ()가 붙는다면 this.renderAverage() 에서 소괄호 빼고 this.renderAverage 이렇게 작성해도 되는건가요? 근데 이렇게 하면 Functions are not valid as a React child 에러가 나더라구요

zerocho님의 프로필 이미지
zerocho
Instructor

renderAverage는 이벤트가 아닙니다

0

zerocho님의 프로필 이미지
zerocho
Instructor

모든 이벤트는 실행될 때 알아서 ()가 붙습니다.

crystalsujeongna2455's profile image
crystalsujeongna2455

asked

Ask a question