componentDidMount
라이프 사이클 메소드에서 클릭 이벤트가 발생하는 구성 요소가 있습니다.구성 요소를 업데이트 할 때 DOM 요소를 클릭하십시오
구성 요소의 렌더링이 트리거 될 때마다 div가 필요합니다.
내 문제는 componentDidMount
한 번만 발생하고 구성 요소가 다시 렌더링 될 때 클릭 이벤트가 발생하지 않는다는 것입니다.
click 이벤트가 작동하는 다른 라이프 사이클 메소드를 찾지 못했습니다.
다른 방법으로도 가능합니까?
크리크 방법 :
componentDidMount() {
this.setState({
audioPlayer: ReactDOM.findDOMNode(this.refs.audio)
},() => {
this.state.audioPlayer.ontimeupdate =() => { this.timeUpdated() };
this.state.audioPlayer.onprogress =() => { this.progressUpdated() };
if(this.props.playing) {
this.divElement.click();
}
});
}
참조하는 사업부 :
<div className='player__control__icons--play'>
<div ref={div => this.divElement = div} className='player__control__icon' onClick={this.togglePlay.bind(this)}>
<Play />
</div>
{skipButtons}
</div>
https://reactjs.org/docs/react-component .html # componentdidupdate 해당 메소드가 원하는 정보 여야합니다. – Jayce444