[React]컴포넌트 이벤트 만들기
사용자 이벤트를 만들기 전에 .bind(this){}라는 녀석을 살펴보자. .bind(this)란, 간단하게 말해서 컴포넌트 그 자체를 가르킨다 ex) Component 따라서 bind(this)를 해주는 경우에는 컴포넌트 자체를 심어준다는 의미이다. 그렇다면 그 에서 사용하는 state 값들을 사용할 수 있다. 사용자 이벤트 만들기 먼저, App.js 위와 같은 코드가 있다고 했을 경우에 해당 div 영역에서 onChangePage 라는 사용자 정의 이벤트를 설치했다고 생각하자. Subject.js import React,{ Component} from 'react'; class Subject extends Component{ render() { return ( {this.props.title} {th..
React
2020. 11. 21. 18:31