-
[15]이벤트 핸들러 또는 콜백에 매개 변수를 전달하는 방법dev/Web 2021. 4. 12. 19:07
화살표 함수를 이용해 파라미터를 전달할 수 있다.
<button onClick={() => this.handleClick(id)} />
.bind를 사용
<button onClick={this.handleClick.bind(this, id)} />
그외
<button onClick={this.handleClick(id)} /> handleClick = (id) => () => { console.log("Hello, your ticket number is", id) };
'dev > Web' 카테고리의 다른 글
[17]인라인 조건식이란? (0) 2021.04.12 [16]합성 이벤트(synthetic events)란? (0) 2021.04.12 [14]JSX 콜백에서 메서드 또는 이벤트 핸들러를 바인딩하는 방법 (0) 2021.04.12 [13]HTML과 React 이벤트 처리의 차이점 (0) 2021.04.12 [12]setState()의 인수로서 콜백 함수의 목적 (0) 2021.04.12