이것은 구성 요소에서 실행되지 않지만 div에 이벤트 처리기를 연결하면 작동합니다. 내 하위 구성 요소에 소품 유형 함수를 전달해야합니까? 당신은 기본적으로 무슨 짓을Reactjs의 구성 요소에 대한 이벤트 처리기
는const buttonStyle = {
color: 'red'
};
class Button extends React.Component {
render() {
return (
<a className="social-button twitter">
<i href="#" className="fa fa-twitter"></i>
</a>
)};
}
class PanelButtons extends React.Component {
constructor(props){
super(props);
}
handleClick() {
console.log('this is:');
}
render() {
return (
<div>
<div onClick={(e) => this.handleClick(e)}> {/*this works attaching it to a div*/}
CLick me
</div>
<div className="social-buttons">
<Button onClick={(e) => this.handleClick(e)} />{/*does now work attaching it to a component*/}
</div>
</div>
)
}
}
ReactDOM.render(<PanelButtons />, document.querySelector('body'));