Something wrong error occured!
I use react js and react-rails gem.
I have a problem.
When I add a onClick attribute to JSX onClick={() => this.handleClick()}
, but it does not work.
If I removed a onClick attribute, It works. Why??
export default class Popup extends React.Component{
constructor(props){
super(props)
}
componentWillMount(){
this.setState({
show: true
})
}
handleClick(){
console.log('name')
}
render(){
return(
<div className={`c-popup c-popup--white ${this.state.show ? 'is-active' : ''}`}>
<article className="c-popup__box">
<button onClick={() => console.log('aiueo')} className="c-popup__box-close"> //Here!!!!!!! It's not working!
<i className="icon ion-close"></i>
</button>
</article>
</div>
)
}
}
export default class Popup extends React.Component{
constructor(props){
super(props)
}
componentWillMount(){
this.setState({
show: true
})
}
handleClick(){
console.log('name')
}
render(){
return(
<div className={`c-popup c-popup--white ${this.state.show ? 'is-active' : ''}`}>
<article className="c-popup__box">
<button className="c-popup__box-close"> //This code is working.
<i className="icon ion-close"></i>
</button>
</article>
</div>
)
}
}
Thank you for your patience with my poor English!