Event

hey hey·2021년 12월 7일
0

React 자료

목록 보기
8/18
post-thumbnail
<div className="Subject">
  <h1><a href="/" onClick={(event)=>{
    event.preventDefault()  새로고침 막기
  }}>
    {this.state.subject.title}</a></h1>
  <p>{this.state.subject.sub} 바보야</p>
</div>
<a href="/" onClick={function(event){
	  if (this.state.mode ==='welcome'){
	  this.setState({ **state 내용 바꾸기** 
	    mode:'read'
	  })}
	  else{ this.setState({mode:'welcome'})}
	}.bind(this)}> 

**setState 를 이용해서 state를 바꿔야 한다.**

**.bind(this) → event handler 안에서 this 사용할 수 있게 만들기**

profile
FE - devp

0개의 댓글